From b29f23e28caa23925af0fe91846bbf254d936493 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 21 Feb 2017 21:01:38 -0500 Subject: [PATCH] extract method for determing network type --- lib/cmds/blockchain/geth_commands.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/cmds/blockchain/geth_commands.js b/lib/cmds/blockchain/geth_commands.js index 83baa7636..02e2ab76a 100644 --- a/lib/cmds/blockchain/geth_commands.js +++ b/lib/cmds/blockchain/geth_commands.js @@ -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();