From 170d8528eba27e2cb02e83d55e0528a2c7f8c398 Mon Sep 17 00:00:00 2001 From: emizzle Date: Tue, 26 Jun 2018 13:34:52 +1000 Subject: [PATCH] When communication is disabled in config, do not run the module in embark. Previous to this change, `Geth: WARN [06-25|16:46:26] origin 'embark' not allowed on WS-RPC interface` would appear in the logs when the module was run while disabled. Updated the cors component so that when `rpcCorsDomain` and `wsOrigins` are set to `'auto'`, and all components are disabled `rpcCorsDomain` and `wsOrigins` are passed as a null parameter to geth as opposed to being passed as `'auto'`. --- lib/core/config.js | 10 ++++++++-- lib/modules/whisper/index.js | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/core/config.js b/lib/core/config.js index 5c755f010..b7fb5b00b 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -123,8 +123,14 @@ Config.prototype._updateBlockchainCors = function(){ } let cors = corsParts.join(','); - if(blockchainConfig.rpcCorsDomain === 'auto' && cors.length) blockchainConfig.rpcCorsDomain = cors; - if(blockchainConfig.wsOrigins === 'auto' && cors.length) blockchainConfig.wsOrigins = cors; + if(blockchainConfig.rpcCorsDomain === 'auto'){ + if(cors.length) blockchainConfig.rpcCorsDomain = cors; + else blockchainConfig.rpcCorsDomain = ''; + } + if(blockchainConfig.wsOrigins === 'auto'){ + if(cors.length) blockchainConfig.wsOrigins = cors; + else blockchainConfig.wsOrigins = ''; + } }; Config.prototype._mergeConfig = function(configFilePath, defaultConfig, env, enabledByDefault) { diff --git a/lib/modules/whisper/index.js b/lib/modules/whisper/index.js index 7206d452b..be1743400 100644 --- a/lib/modules/whisper/index.js +++ b/lib/modules/whisper/index.js @@ -13,6 +13,10 @@ class Whisper { this.web3 = new Web3(); this.embark = embark; + if (!this.communicationConfig.enabled) { + return; + } + this.connectToProvider(); this.setServiceCheck(); this.addWhisperToEmbarkJS();