refactor to use commonOptions method

This commit is contained in:
Iuri Matias 2016-10-30 20:21:28 -04:00
parent a5bc17f0de
commit 6920ae9481
1 changed files with 15 additions and 42 deletions

View File

@ -4,48 +4,6 @@ var GethCommands = function(options) {
this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)"; this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
}; };
GethCommands.prototype.initGenesisCommmand = function() {
var config = this.config;
var cmd = "geth ";
if (config.networkType === 'testnet') {
cmd += "--testnet ";
} else if (config.networkType === 'olympic') {
cmd += "--olympic ";
}
if (config.datadir) {
cmd += "--datadir=\"" + config.datadir + "\" ";
}
if (config.genesisBlock) {
cmd += "init \"" + config.genesisBlock + "\" ";
}
return cmd;
};
GethCommands.prototype.newAccountCommand = function() {
var config = this.config;
var cmd = "geth ";
if (config.networkType === 'testnet') {
cmd += "--testnet ";
} else if (config.networkType === 'olympic') {
cmd += "--olympic ";
}
if (config.datadir) {
cmd += "--datadir=\"" + config.datadir + "\" ";
}
if (config.account && config.account.password) {
cmd += "--password " + config.account.password + " ";
}
return cmd + "account new ";
};
GethCommands.prototype.commonOptions = function() { GethCommands.prototype.commonOptions = function() {
var config = this.config; var config = this.config;
var cmd = ""; var cmd = "";
@ -69,6 +27,21 @@ GethCommands.prototype.commonOptions = function() {
return cmd; return cmd;
}; };
GethCommands.prototype.initGenesisCommmand = function() {
var config = this.config;
var cmd = "geth " + this.commonOptions();
if (config.genesisBlock) {
cmd += "init \"" + config.genesisBlock + "\" ";
}
return cmd;
};
GethCommands.prototype.newAccountCommand = function() {
return "geth " + this.commonOptions() + "account new ";
};
GethCommands.prototype.listAccountsCommand = function() { GethCommands.prototype.listAccountsCommand = function() {
return "geth " + this.commonOptions() + "account list "; return "geth " + this.commonOptions() + "account list ";
}; };