From 6ff72432d6a21173bd290715038e3a1e88bbe777 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 29 Jul 2015 21:40:49 -0400 Subject: [PATCH] make maxpeers configurable --- boilerplate/config/blockchain.yml | 3 +++ lib/blockchain.js | 2 +- lib/config/blockchain.js | 1 + test/blockchain.js | 2 +- test/config.blockchain.js | 2 ++ 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index 0457f510..7efb2258 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -6,6 +6,7 @@ development: genesis_block: config/genesis.json datadir: /tmp/embark mine_when_needed: true + max_peers: 0 gas_limit: 500000 gas_price: 10000000000000 console: false @@ -18,6 +19,7 @@ staging: rpc_whitelist: "*" datadir: default network_id: 0 + max_peers: 4 console: true account: init: false @@ -28,6 +30,7 @@ production: rpc_whitelist: "*" datadir: default network_id: 1 + max_peers: 4 console: true account: init: false diff --git a/lib/blockchain.js b/lib/blockchain.js index 23e46681..3b15b77a 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -31,7 +31,7 @@ Blockchain.prototype.generate_basic_command = function() { } //TODO: this should be configurable - cmd += "--maxpeers 0 "; + cmd += "--maxpeers " + config.maxPeers + " "; if (config.account.password !== void 0) { cmd += "--password " + config.account.password + " "; diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index ec20cee6..935ba130 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -41,6 +41,7 @@ BlockchainConfig.prototype.config = function(env) { genesisBlock: config.genesis_block, datadir: config.datadir, networkId: networkId, + maxPeers: 4, port: config.port || "30303", console_toggle: config.console || false, mine_when_needed: config.mine_when_needed || false, diff --git a/test/blockchain.js b/test/blockchain.js index 527ccf71..3f3cca23 100644 --- a/test/blockchain.js +++ b/test/blockchain.js @@ -10,7 +10,7 @@ describe('embark.blockchain', function() { var blockchain = new Blockchain(blockchainConfig); it('should return correct cmd', function() { - assert.strictEqual(blockchain.generate_basic_command(), "geth --datadir=\"/tmp/embark\" --logfile=\"/tmp/embark.log\" --port 30303 --rpc --rpcport 8101 --networkid "+blockchainConfig.networkId+" --rpccorsdomain \"*\" --minerthreads \"1\" --mine --genesis=\"config/genesis.json\" --maxpeers 0 --password config/password "); + assert.strictEqual(blockchain.generate_basic_command(), "geth --datadir=\"/tmp/embark\" --logfile=\"/tmp/embark.log\" --port 30303 --rpc --rpcport 8101 --networkid "+blockchainConfig.networkId+" --rpccorsdomain \"*\" --minerthreads \"1\" --mine --genesis=\"config/genesis.json\" --maxpeers 4 --password config/password "); }); }); diff --git a/test/config.blockchain.js b/test/config.blockchain.js index 7930ce67..fa86e16e 100644 --- a/test/config.blockchain.js +++ b/test/config.blockchain.js @@ -67,6 +67,7 @@ describe('embark.config.blockchain', function() { genesisBlock: 'config/genesis.json', datadir: '/tmp/embark', networkId: 0, + maxPeers: 4, port: "30303", console_toggle: false, mine_when_needed: true, @@ -108,6 +109,7 @@ describe('embark.config.blockchain', function() { genesisBlock: undefined, datadir: '/tmp/embark', networkId: 0, + maxPeers: 4, port: "30303", console_toggle: false, mine_when_needed: true,