make embark blockchain compatible with latest geth
This commit is contained in:
parent
c168d103cb
commit
faf626be93
|
@ -39,7 +39,10 @@
|
|||
miner_obj.start(config.threads);
|
||||
return;
|
||||
}
|
||||
miner_obj.stop(config.threads);
|
||||
|
||||
// TODO: check why it's no longer accepting this param
|
||||
//miner_obj.stop(config.threads);
|
||||
miner_obj.stop();
|
||||
|
||||
fundAccount(config, miner_obj, function () {
|
||||
if (config.mine_periodically) start_periodic_mining(config, miner_obj);
|
||||
|
|
|
@ -4,6 +4,38 @@ Blockchain = function(blockchainConfig) {
|
|||
this.config = blockchainConfig;
|
||||
}
|
||||
|
||||
Blockchain.prototype.generate_genesis_init_command = function() {
|
||||
var config = this.config;
|
||||
var address = config.account.address;
|
||||
|
||||
var cmd = "geth ";
|
||||
|
||||
if (config.datadir !== "default") {
|
||||
cmd += "--datadir=\"" + config.datadir + "\" ";
|
||||
}
|
||||
|
||||
cmd += "init \"" + config.genesisBlock + "\" ";
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Blockchain.prototype.generate_init_command = function() {
|
||||
var config = this.config;
|
||||
var address = config.account.address;
|
||||
|
||||
var cmd = "geth ";
|
||||
|
||||
if (config.datadir !== "default") {
|
||||
cmd += "--datadir=\"" + config.datadir + "\" ";
|
||||
}
|
||||
|
||||
if (config.account.password !== void 0) {
|
||||
cmd += "--password " + config.account.password + " ";
|
||||
}
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Blockchain.prototype.generate_basic_command = function() {
|
||||
var config = this.config;
|
||||
var address = config.account.address;
|
||||
|
@ -15,6 +47,10 @@ Blockchain.prototype.generate_basic_command = function() {
|
|||
cmd += "--datadir=\"" + config.datadir + "\" ";
|
||||
}
|
||||
|
||||
if (config.account.password !== void 0) {
|
||||
cmd += "--password " + config.account.password + " ";
|
||||
}
|
||||
|
||||
if (config.geth_extra_opts) {
|
||||
cmd += config.geth_extra_opts + " ";
|
||||
}
|
||||
|
@ -24,7 +60,7 @@ Blockchain.prototype.generate_basic_command = function() {
|
|||
cmd += "--rpcport " + config.rpcPort + " ";
|
||||
cmd += "--rpcaddr " + config.rpcHost + " ";
|
||||
cmd += "--networkid " + config.networkId + " ";
|
||||
cmd += "--rpccorsdomain " + config.rpcWhitelist + " ";
|
||||
cmd += "--rpccorsdomain=\"" + config.rpcWhitelist + "\" ";
|
||||
|
||||
if(config.testnet){
|
||||
cmd += "--testnet "
|
||||
|
@ -34,12 +70,9 @@ Blockchain.prototype.generate_basic_command = function() {
|
|||
cmd += "--minerthreads \"" + config.minerthreads + "\" ";
|
||||
}
|
||||
|
||||
if(config.mine)
|
||||
if(config.mine_when_needed || config.mine)
|
||||
cmd += "--mine ";
|
||||
|
||||
if (config.genesisBlock !== void 0)
|
||||
cmd += "--genesis=\"" + config.genesisBlock + "\" ";
|
||||
|
||||
if (config.whisper) {
|
||||
cmd += "--shh ";
|
||||
rpc_api.push('shh')
|
||||
|
@ -50,19 +83,15 @@ Blockchain.prototype.generate_basic_command = function() {
|
|||
//TODO: this should be configurable
|
||||
cmd += "--maxpeers " + config.maxPeers + " ";
|
||||
|
||||
if (config.account.password !== void 0) {
|
||||
cmd += "--password " + config.account.password + " ";
|
||||
}
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Blockchain.prototype.list_command = function() {
|
||||
return this.generate_basic_command() + "account list ";
|
||||
return this.generate_init_command() + "account list ";
|
||||
}
|
||||
|
||||
Blockchain.prototype.init_command = function() {
|
||||
return this.generate_basic_command() + "account new ";
|
||||
return this.generate_init_command() + "account new ";
|
||||
}
|
||||
|
||||
Blockchain.prototype.geth_command = function(geth_args) {
|
||||
|
@ -74,7 +103,7 @@ Blockchain.prototype.run_command = function(address, use_tmp) {
|
|||
var config = this.config;
|
||||
|
||||
if (address !== void 0) {
|
||||
cmd += "--unlock " + address + " ";
|
||||
cmd += "--unlock=" + address + " ";
|
||||
}
|
||||
|
||||
if (config.bootNodes !== undefined && config.bootNodes.boot == true) {
|
||||
|
@ -118,13 +147,19 @@ Blockchain.prototype.get_address = function() {
|
|||
console.log("running: " + this.list_command());
|
||||
result = exec(this.list_command());
|
||||
|
||||
if (result.output.indexOf("Fatal") < 0) {
|
||||
console.log("=== already initialized");
|
||||
address = result.output.match(/{(\w+)}/)[1];
|
||||
} else {
|
||||
if (result.output === undefined || result.output === '' || result.output.indexOf("Fatal") >= 0) {
|
||||
if (config.genesisBlock !== void 0) {
|
||||
console.log("initializing genesis block")
|
||||
console.log("running: " + this.generate_genesis_init_command());
|
||||
result = exec(this.generate_genesis_init_command());
|
||||
}
|
||||
|
||||
console.log("running: " + this.init_command());
|
||||
result = exec(this.init_command());
|
||||
address = result.output.match(/{(\w+)}/)[1];
|
||||
} else {
|
||||
console.log("=== already initialized");
|
||||
address = result.output.match(/{(\w+)}/)[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue