2015-06-28 02:20:07 +00:00
|
|
|
var Deploy;
|
2015-06-28 13:51:58 +00:00
|
|
|
var Config = require('./config/config.js');
|
2015-06-28 02:20:07 +00:00
|
|
|
|
|
|
|
startChain = function(env) {
|
2015-06-28 13:51:58 +00:00
|
|
|
config = (new Config.Blockchain()).loadConfigFile('config/blockchain.yml').config(env);
|
2015-06-28 02:20:07 +00:00
|
|
|
|
2015-06-28 13:51:58 +00:00
|
|
|
address = config.account.address;
|
2015-06-28 02:20:07 +00:00
|
|
|
|
|
|
|
cmd = "geth ";
|
|
|
|
|
2015-06-28 13:51:58 +00:00
|
|
|
if (config.datadir !== "default") {
|
|
|
|
cmd += "--datadir=\"" + config.datadir + "\" ";
|
|
|
|
cmd += "--logfile=\"" + config.datadir + ".log\" ";
|
2015-06-28 02:20:07 +00:00
|
|
|
}
|
|
|
|
|
2015-06-28 13:51:58 +00:00
|
|
|
cmd += "--port " + config.port + " ";
|
2015-06-28 02:20:07 +00:00
|
|
|
cmd += "--rpc ";
|
2015-06-28 13:51:58 +00:00
|
|
|
cmd += "--rpcport " + config.rpcPort + " ";
|
|
|
|
cmd += "--networkid " + config.networkId + " ";
|
|
|
|
cmd += "--rpccorsdomain \"" + config.rpcWhitelist + "\" ";
|
2015-06-28 02:20:07 +00:00
|
|
|
|
2015-06-28 13:51:58 +00:00
|
|
|
if (config.minerthreads !== void 0) {
|
|
|
|
cmd += "--minerthreads \"" + config.minerthreads + "\" ";
|
2015-06-28 02:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd += "--mine ";
|
2015-07-01 18:00:17 +00:00
|
|
|
cmd += "--maxpeers 0 ";
|
2015-06-28 02:20:07 +00:00
|
|
|
|
2015-06-28 13:51:58 +00:00
|
|
|
if (config.account.password !== void 0) {
|
|
|
|
cmd += "--password " + config.account.password + " ";
|
2015-06-28 02:20:07 +00:00
|
|
|
}
|
|
|
|
|
2015-06-28 13:51:58 +00:00
|
|
|
if (config.account.init) {
|
2015-06-28 02:20:07 +00:00
|
|
|
console.log("=== initializating account");
|
|
|
|
console.log("running: " + cmd + " account list");
|
|
|
|
result = exec(cmd + "account list");
|
|
|
|
console.log("finished");
|
|
|
|
console.log("=== output is " + result.output);
|
|
|
|
if (result.output.indexOf("Fatal") < 0) {
|
|
|
|
console.log("=== already initialized");
|
|
|
|
address = result.output.match(/{(\w+)}/)[1];
|
|
|
|
} else {
|
|
|
|
console.log("running: " + cmd + " account new");
|
|
|
|
output = exec(cmd + " account new");
|
|
|
|
address = output.output.match(/{(\w+)}/)[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (address !== void 0) {
|
|
|
|
cmd += "--unlock " + address + " ";
|
|
|
|
}
|
|
|
|
|
2015-06-28 13:51:58 +00:00
|
|
|
if (config.console_toggle) {
|
2015-06-28 02:20:07 +00:00
|
|
|
cmd += "console";
|
|
|
|
}
|
|
|
|
|
2015-06-28 13:51:58 +00:00
|
|
|
if (config.mine_when_needed) {
|
2015-06-28 02:20:07 +00:00
|
|
|
cmd += "js node_modules/embark-framework/js/mine.js";
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("running: " + cmd);
|
|
|
|
|
|
|
|
console.log("=== running geth");
|
|
|
|
|
|
|
|
exec(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
Blockchain = {
|
|
|
|
startChain: startChain
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Blockchain
|
|
|
|
|