extract method for determing network type

This commit is contained in:
Iuri Matias 2017-02-21 21:01:38 -05:00
parent d67982ac71
commit b29f23e28c

View File

@ -1,4 +1,5 @@
// TODO: make all of this async
var GethCommands = function(options) {
this.config = options.config;
this.env = options.env || 'development';
@ -10,13 +11,7 @@ GethCommands.prototype.commonOptions = function() {
var config = this.config;
var cmd = "";
if (config.networkType === 'testnet') {
cmd += "--testnet ";
} else if (config.networkType === 'olympic') {
cmd += "--olympic ";
} else if (config.networkType === 'custom') {
cmd += "--networkid " + config.networkId + " ";
}
cmd += this.determineNetworkType(config);
if (config.datadir) {
cmd += "--datadir=\"" + config.datadir + "\" ";
@ -37,6 +32,18 @@ GethCommands.prototype.commonOptions = function() {
return cmd;
};
GethCommands.prototype.determineNetworkType = function(config) {
var cmd = "";
if (config.networkType === 'testnet') {
cmd += "--testnet ";
} else if (config.networkType === 'olympic') {
cmd += "--olympic ";
} else if (config.networkType === 'custom') {
cmd += "--networkid " + config.networkId + " ";
}
return cmd;
};
GethCommands.prototype.initGenesisCommmand = function() {
var config = this.config;
var cmd = this.geth_bin + " " + this.commonOptions();