diff --git a/lib/modules/ipfs/index.js b/lib/modules/ipfs/index.js index f25d156e2..775756294 100644 --- a/lib/modules/ipfs/index.js +++ b/lib/modules/ipfs/index.js @@ -17,6 +17,10 @@ class IPFS { this.webServerConfig = embark.config.webServerConfig; this.blockchainConfig = embark.config.blockchainConfig; + if (!this.isIpfsEnabledInTheConfig()) { + return + } + this.setServiceCheck(); this.addProviderToEmbarkJS(); this.addObjectToConsole(); @@ -34,10 +38,6 @@ class IPFS { setServiceCheck() { let self = this; - if (!this.isIpfsEnabledInTheConfig()) { - return - } - self.events.on('check:backOnline:IPFS', function () { self.logger.info(__('IPFS node detected') + '..'); }); @@ -83,9 +83,6 @@ class IPFS { addProviderToEmbarkJS() { const self = this; - if (!this.isIpfsEnabledInTheConfig()) { - return - } self.events.request("version:get:ipfs-api", function(ipfsApiVersion) { let currentIpfsApiVersion = require('../../../package.json').dependencies["ipfs-api"]; diff --git a/lib/modules/swarm/index.js b/lib/modules/swarm/index.js index db91d3cbb..46e1a24e1 100644 --- a/lib/modules/swarm/index.js +++ b/lib/modules/swarm/index.js @@ -22,6 +22,10 @@ class Swarm { this.getUrl = this.storageConfig.upload.getUrl || this.providerUrl + '/bzz:/'; + if (!this.isSwarmEnabledInTheConfig()) { + return; + } + this.bzz = new Web3Bzz(this.providerUrl); this.setServiceCheck(); @@ -41,10 +45,6 @@ class Swarm { setServiceCheck() { let self = this; - if (!this.isSwarmEnabledInTheConfig()) { - return; - } - this.events.on('check:backOnline:Swarm', function () { self.logger.info(__('Swarm node detected...')); }); @@ -73,10 +73,6 @@ class Swarm { } addProviderToEmbarkJS() { - if (!this.isSwarmEnabledInTheConfig()) { - return; - } - let code = ""; code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString(); code += "\nEmbarkJS.Storage.registerProvider('swarm', __embarkSwarm);";