From 5c283b523269bf8864717e413e0e03355ee732f5 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 30 Oct 2016 20:35:11 -0400 Subject: [PATCH] support maxpeers option --- boilerplate/config/blockchain.json | 1 + demo/config/blockchain.json | 1 + lib/blockchain.js | 3 ++- lib/geth_commands.js | 2 ++ test/blockchain.js | 2 ++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/boilerplate/config/blockchain.json b/boilerplate/config/blockchain.json index 335e6e49..fcecfbbe 100644 --- a/boilerplate/config/blockchain.json +++ b/boilerplate/config/blockchain.json @@ -5,6 +5,7 @@ "datadir": ".embark/development/datadir", "mineWhenNeeded": true, "nodiscover": true, + "maxpeers": 0, "rpcHost": "localhost", "rpcPort": 8545, "rpcCorsDomain": "http://localhost:8000", diff --git a/demo/config/blockchain.json b/demo/config/blockchain.json index 335e6e49..fcecfbbe 100644 --- a/demo/config/blockchain.json +++ b/demo/config/blockchain.json @@ -5,6 +5,7 @@ "datadir": ".embark/development/datadir", "mineWhenNeeded": true, "nodiscover": true, + "maxpeers": 0, "rpcHost": "localhost", "rpcPort": 8545, "rpcCorsDomain": "http://localhost:8000", diff --git a/lib/blockchain.js b/lib/blockchain.js index c8e60f58..4ddbc5a9 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -20,7 +20,8 @@ var Blockchain = function(blockchainConfig, Client) { nodiscover: this.blockchainConfig.nodiscover || false, mine: this.blockchainConfig.mine || false, account: this.blockchainConfig.account || {}, - whisper: (this.blockchainConfig.whisper === undefined) || this.blockchainConfig.whisper + whisper: (this.blockchainConfig.whisper === undefined) || this.blockchainConfig.whisper, + maxpeers: this.blockchainConfig.maxpeers || 25 }; this.client = new Client({config: this.config}); diff --git a/lib/geth_commands.js b/lib/geth_commands.js index 88369d35..575a1c9f 100644 --- a/lib/geth_commands.js +++ b/lib/geth_commands.js @@ -74,6 +74,8 @@ GethCommands.prototype.mainCommand = function(address) { cmd += "--nodiscover "; } + cmd += "--maxpeers " + config.maxpeers + " "; + if (config.mineWhenNeeded || config.mine) { cmd += "--mine "; } diff --git a/test/blockchain.js b/test/blockchain.js index 45f1e3d9..5d17d28f 100644 --- a/test/blockchain.js +++ b/test/blockchain.js @@ -22,6 +22,7 @@ describe('embark.Blockchain', function() { networkId: 12301, port: 30303, nodiscover: false, + maxpeers: 25, mine: false, whisper: true, account: {} @@ -45,6 +46,7 @@ describe('embark.Blockchain', function() { networkId: 1, port: 123456, nodiscover: true, + maxpeers: 25, mine: true, whisper: false, account: {}