mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-12 06:44:37 +00:00
Merge pull request #401 from embark-framework/bug_fix/blockchain-dev
Use --dev when in development
This commit is contained in:
commit
f85017e3f4
@ -50,12 +50,26 @@ var Blockchain = function(options) {
|
|||||||
this.config.datadir = fs.embarkPath(".embark/development/datadir");
|
this.config.datadir = fs.embarkPath(".embark/development/datadir");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client = new options.client({config: this.config, env: this.env});
|
if (this.blockchainConfig.isDev) {
|
||||||
|
this.isDev = true;
|
||||||
|
} else if (this.blockchainConfig.isDev === false) {
|
||||||
|
this.isDev = false;
|
||||||
|
} else {
|
||||||
|
this.isDev = this.env === 'development';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.client = new options.client({config: this.config, env: this.env, isDev: this.isDev});
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockchain.prototype.runCommand = function(cmd, options) {
|
Blockchain.prototype.runCommand = function(cmd, options) {
|
||||||
console.log(("running: " + cmd.underline).green);
|
console.log(("running: " + cmd.underline).green);
|
||||||
return shelljs.exec(cmd, options);
|
return shelljs.exec(cmd, options, (err, stdout, _stderr) => {
|
||||||
|
if (err && this.env === 'development' && stdout.indexOf('Failed to unlock developer account') > 0) {
|
||||||
|
console.warn('\nDevelopment blockchain has changed to use the --dev option.'.yellow);
|
||||||
|
console.warn('You can reset your workspace to fix the problem with'.yellow + ' embark reset'.cyan);
|
||||||
|
console.warn('Otherwise, you can change your data directory in blockchain.json (datadir)'.yellow);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockchain.prototype.run = function() {
|
Blockchain.prototype.run = function() {
|
||||||
@ -69,7 +83,10 @@ Blockchain.prototype.run = function() {
|
|||||||
console.log(("could not find " + this.config.geth_bin + " command; is " + this.client.name + " installed or in the PATH?").green);
|
console.log(("could not find " + this.config.geth_bin + " command; is " + this.client.name + " installed or in the PATH?").green);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var address = this.initChainAndGetAddress();
|
let address = '';
|
||||||
|
if (!this.isDev) {
|
||||||
|
address = this.initChainAndGetAddress();
|
||||||
|
}
|
||||||
this.client.mainCommand(address, function(cmd) {
|
this.client.mainCommand(address, function(cmd) {
|
||||||
self.runCommand(cmd, {async: true});
|
self.runCommand(cmd, {async: true});
|
||||||
});
|
});
|
||||||
|
@ -5,6 +5,7 @@ class GethCommands {
|
|||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.config = options && options.hasOwnProperty('config') ? options.config : {};
|
this.config = options && options.hasOwnProperty('config') ? options.config : {};
|
||||||
this.env = options && options.hasOwnProperty('env') ? options.env : 'development';
|
this.env = options && options.hasOwnProperty('env') ? options.env : 'development';
|
||||||
|
this.isDev = options && options.hasOwnProperty('isDev') ? options.isDev : (this.env === 'development');
|
||||||
this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
|
this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
|
||||||
this.geth_bin = this.config.geth_bin || "geth";
|
this.geth_bin = this.config.geth_bin || "geth";
|
||||||
}
|
}
|
||||||
@ -188,7 +189,7 @@ class GethCommands {
|
|||||||
} else {
|
} else {
|
||||||
accountAddress = address;
|
accountAddress = address;
|
||||||
}
|
}
|
||||||
if (accountAddress) {
|
if (accountAddress && !self.isDev) {
|
||||||
return callback(null, "--unlock=" + accountAddress);
|
return callback(null, "--unlock=" + accountAddress);
|
||||||
}
|
}
|
||||||
callback(null, "");
|
callback(null, "");
|
||||||
@ -200,10 +201,16 @@ class GethCommands {
|
|||||||
callback(null, "");
|
callback(null, "");
|
||||||
},
|
},
|
||||||
function mineWhenNeeded(callback) {
|
function mineWhenNeeded(callback) {
|
||||||
if (config.mineWhenNeeded) {
|
if (config.mineWhenNeeded && !self.isDev) {
|
||||||
return callback(null, "js .embark/" + self.env + "/js/mine.js");
|
return callback(null, "js .embark/" + self.env + "/js/mine.js");
|
||||||
}
|
}
|
||||||
callback(null, "");
|
callback(null, "");
|
||||||
|
},
|
||||||
|
function isDev(callback) {
|
||||||
|
if (self.isDev) {
|
||||||
|
return callback(null, '--dev');
|
||||||
|
}
|
||||||
|
callback(null, '');
|
||||||
}
|
}
|
||||||
], function (err, results) {
|
], function (err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"networkType": "custom",
|
"networkType": "custom",
|
||||||
"genesisBlock": "config/development/genesis.json",
|
"genesisBlock": "config/development/genesis.json",
|
||||||
"datadir": ".embark/development/datadir",
|
"datadir": ".embark/development/datadir",
|
||||||
|
"isDev": true,
|
||||||
"mineWhenNeeded": true,
|
"mineWhenNeeded": true,
|
||||||
"nodiscover": true,
|
"nodiscover": true,
|
||||||
"maxpeers": 0,
|
"maxpeers": 0,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"networkType": "custom",
|
"networkType": "custom",
|
||||||
"genesisBlock": "config/development/genesis.json",
|
"genesisBlock": "config/development/genesis.json",
|
||||||
"datadir": ".embark/development/datadir",
|
"datadir": ".embark/development/datadir",
|
||||||
|
"isDev": true,
|
||||||
"mineWhenNeeded": true,
|
"mineWhenNeeded": true,
|
||||||
"nodiscover": true,
|
"nodiscover": true,
|
||||||
"maxpeers": 0,
|
"maxpeers": 0,
|
||||||
|
@ -22,6 +22,7 @@ describe('embark.Config', function () {
|
|||||||
"networkType": "custom",
|
"networkType": "custom",
|
||||||
"genesisBlock": "config/development/genesis.json",
|
"genesisBlock": "config/development/genesis.json",
|
||||||
"datadir": ".embark/development/datadir",
|
"datadir": ".embark/development/datadir",
|
||||||
|
"isDev": true,
|
||||||
"mineWhenNeeded": true,
|
"mineWhenNeeded": true,
|
||||||
"nodiscover": true,
|
"nodiscover": true,
|
||||||
"rpcHost": "localhost",
|
"rpcHost": "localhost",
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"networkType": "custom",
|
"networkType": "custom",
|
||||||
"genesisBlock": "config/development/genesis.json",
|
"genesisBlock": "config/development/genesis.json",
|
||||||
"datadir": ".embark/development/datadir",
|
"datadir": ".embark/development/datadir",
|
||||||
|
"isDev": true,
|
||||||
"mineWhenNeeded": true,
|
"mineWhenNeeded": true,
|
||||||
"nodiscover": true,
|
"nodiscover": true,
|
||||||
"rpcHost": "localhost",
|
"rpcHost": "localhost",
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"networkType": "custom",
|
"networkType": "custom",
|
||||||
"genesisBlock": "development/genesis.json",
|
"genesisBlock": "development/genesis.json",
|
||||||
"datadir": ".embark/development/datadir",
|
"datadir": ".embark/development/datadir",
|
||||||
|
"isDev": true,
|
||||||
"mineWhenNeeded": true,
|
"mineWhenNeeded": true,
|
||||||
"nodiscover": true,
|
"nodiscover": true,
|
||||||
"maxpeers": 0,
|
"maxpeers": 0,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"networkType": "custom",
|
"networkType": "custom",
|
||||||
"genesisBlock": "config/development/genesis.json",
|
"genesisBlock": "config/development/genesis.json",
|
||||||
"datadir": ".embark/development/datadir",
|
"datadir": ".embark/development/datadir",
|
||||||
|
"isDev": true,
|
||||||
"mineWhenNeeded": true,
|
"mineWhenNeeded": true,
|
||||||
"nodiscover": true,
|
"nodiscover": true,
|
||||||
"maxpeers": 0,
|
"maxpeers": 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user