From e58671e74248fcaa576f6d6c4460ed49861da70f Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 30 Oct 2016 20:08:45 -0400 Subject: [PATCH] refactor common geth command options into the a common method --- lib/geth_commands.js | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/lib/geth_commands.js b/lib/geth_commands.js index fdb7cef3..73de5333 100644 --- a/lib/geth_commands.js +++ b/lib/geth_commands.js @@ -46,9 +46,9 @@ GethCommands.prototype.newAccountCommand = function() { return cmd + "account new "; }; -GethCommands.prototype.listAccountsCommand = function() { +GethCommands.prototype.commonOptions = function() { var config = this.config; - var cmd = "geth "; + var cmd = ""; if (config.networkType === 'testnet') { cmd += "--testnet "; @@ -66,7 +66,11 @@ GethCommands.prototype.listAccountsCommand = function() { cmd += "--password " + config.account.password + " "; } - return cmd + "account list "; + return cmd; +}; + +GethCommands.prototype.listAccountsCommand = function() { + return "geth " + this.commonOptions() + "account list "; }; GethCommands.prototype.mainCommand = function(address) { @@ -74,21 +78,7 @@ GethCommands.prototype.mainCommand = function(address) { var cmd = "geth "; var rpc_api = ['eth', 'web3']; - if (config.datadir) { - cmd += "--datadir=\"" + config.datadir + "\" "; - } - - if (config.networkType === 'testnet') { - cmd += "--testnet "; - } else if (config.networkType === 'olympic') { - cmd += "--olympic "; - } else if (config.networkType === 'custom') { - cmd += "--networkid " + config.networkId + " "; - } - - if (config.account && config.account.password) { - cmd += "--password " + config.account.password + " "; - } + cmd += this.commonOptions(); cmd += "--port " + "30303" + " "; cmd += "--rpc ";