From 9fd39f36baa16564bab8ad3194d3b49963d66a49 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 11 Jan 2018 08:55:28 -0500 Subject: [PATCH] add websocket config to blockchain config --- lib/cmds/blockchain/blockchain.js | 1 + lib/cmds/blockchain/geth_commands.js | 26 ++++++++++++++------------ test_app/config/blockchain.json | 6 +++++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/cmds/blockchain/blockchain.js b/lib/cmds/blockchain/blockchain.js index 59c1f2d1..83aa747b 100644 --- a/lib/cmds/blockchain/blockchain.js +++ b/lib/cmds/blockchain/blockchain.js @@ -28,6 +28,7 @@ var Blockchain = function(options) { maxpeers: ((this.blockchainConfig.maxpeers === 0) ? 0 : (this.blockchainConfig.maxpeers || 25)), bootnodes: this.blockchainConfig.bootnodes || "", rpcApi: (this.blockchainConfig.rpcApi || ['eth', 'web3', 'net']), + wsRPC: (this.blockchainConfig.wsRPC === undefined) || this.blockchainConfig.wsRPC, wsHost: this.blockchainConfig.wsHost || 'localhost', wsPort: this.blockchainConfig.wsPort || 8546, wsOrigins: this.blockchainConfig.wsOrigins || false, diff --git a/lib/cmds/blockchain/geth_commands.js b/lib/cmds/blockchain/geth_commands.js index 9b04e0e4..2e25f2ef 100644 --- a/lib/cmds/blockchain/geth_commands.js +++ b/lib/cmds/blockchain/geth_commands.js @@ -96,21 +96,23 @@ class GethCommands { determineWsOptions(config) { let cmd = ""; - cmd += "--ws "; - cmd += "--wsport " + config.wsPort + " "; - cmd += "--wsaddr " + config.wsHost + " "; - if (config.wsOrigins) { - if (config.wsOrigins === '*') { + if (config.wsRPC) { + cmd += "--ws "; + cmd += "--wsport " + config.wsPort + " "; + cmd += "--wsaddr " + config.wsHost + " "; + if (config.wsOrigins) { + if (config.wsOrigins === '*') { + console.log('=================================='); + console.log('rpcCorsDomain set to *'); + console.log('make sure you know what you are doing'); + console.log('=================================='); + } + cmd += "--wsorigins \"" + config.wsOrigins + "\" "; + } else { console.log('=================================='); - console.log('rpcCorsDomain set to *'); - console.log('make sure you know what you are doing'); + console.log('warning: cors is not set'); console.log('=================================='); } - cmd += "--wsorigins \"" + config.wsOrigins + "\" "; - } else { - console.log('=================================='); - console.log('warning: cors is not set'); - console.log('=================================='); } return cmd; diff --git a/test_app/config/blockchain.json b/test_app/config/blockchain.json index 816d82c3..b23fea5f 100644 --- a/test_app/config/blockchain.json +++ b/test_app/config/blockchain.json @@ -13,7 +13,11 @@ "account": { "password": "config/development/password" }, - "wsOrigins": "http://localhost:8000" + "wsOrigins": "http://localhost:8000", + "wsRPC": true, + "wsHost": "localhost", + "wsPort": 8546 + }, "testnet": { "networkType": "testnet",