From c4e13f9ea8e9cb00167483a78ee867d7e5c7621c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 15 Dec 2017 18:02:50 -0500 Subject: [PATCH] minor refactor on setprovider code --- lib/contracts/code_generator.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/contracts/code_generator.js b/lib/contracts/code_generator.js index d4d73143..4d5d8467 100644 --- a/lib/contracts/code_generator.js +++ b/lib/contracts/code_generator.js @@ -220,15 +220,12 @@ class CodeGenerator { result += Templates.define_when_env_loaded(); let block; + //if (self.communicationConfig.enabled === true && ['whisper', 'orbit'].indexOf(self.communicationConfig.provider) < 0) { + // //TODO: add logger; also make sure it would still work with a plugin provider + // self.logger.warn("unknown provider " + self.communicationConfig.provider); + //} // TODO: refactor this - if (self.communicationConfig.provider === 'whisper' && self.communicationConfig.enabled === true) { - if (self.communicationConfig.connection === undefined) { - block = "\nEmbarkJS.Messages.setProvider('" + self.communicationConfig.provider + "');"; - } else { - block = "\nEmbarkJS.Messages.setProvider('" + self.communicationConfig.provider + "', {server: '" + self.communicationConfig.connection.host + "', port: '" + self.communicationConfig.connection.port + "', type: '" + self.communicationConfig.connection.type + "'});"; - } - result += Templates.exec_when_env_loaded({block: block}); - } else if (self.communicationConfig.provider === 'orbit' && self.communicationConfig.enabled === true) { + if (self.communicationConfig.enabled === true) { if (self.communicationConfig.connection === undefined) { block = "\nEmbarkJS.Messages.setProvider('" + self.communicationConfig.provider + "');"; } else { @@ -236,7 +233,6 @@ class CodeGenerator { } result += Templates.exec_when_env_loaded({block: block}); } - return result; }