move storage config check to the constructor

This commit is contained in:
Iuri Matias 2018-07-08 21:28:43 +03:00
parent 1bd0e8966b
commit 2c478e26ff
2 changed files with 8 additions and 15 deletions

View File

@ -17,6 +17,10 @@ class IPFS {
this.webServerConfig = embark.config.webServerConfig; this.webServerConfig = embark.config.webServerConfig;
this.blockchainConfig = embark.config.blockchainConfig; this.blockchainConfig = embark.config.blockchainConfig;
if (!this.isIpfsEnabledInTheConfig()) {
return
}
this.setServiceCheck(); this.setServiceCheck();
this.addProviderToEmbarkJS(); this.addProviderToEmbarkJS();
this.addObjectToConsole(); this.addObjectToConsole();
@ -34,10 +38,6 @@ class IPFS {
setServiceCheck() { setServiceCheck() {
let self = this; let self = this;
if (!this.isIpfsEnabledInTheConfig()) {
return
}
self.events.on('check:backOnline:IPFS', function () { self.events.on('check:backOnline:IPFS', function () {
self.logger.info(__('IPFS node detected') + '..'); self.logger.info(__('IPFS node detected') + '..');
}); });
@ -83,9 +83,6 @@ class IPFS {
addProviderToEmbarkJS() { addProviderToEmbarkJS() {
const self = this; const self = this;
if (!this.isIpfsEnabledInTheConfig()) {
return
}
self.events.request("version:get:ipfs-api", function(ipfsApiVersion) { self.events.request("version:get:ipfs-api", function(ipfsApiVersion) {
let currentIpfsApiVersion = require('../../../package.json').dependencies["ipfs-api"]; let currentIpfsApiVersion = require('../../../package.json').dependencies["ipfs-api"];

View File

@ -22,6 +22,10 @@ class Swarm {
this.getUrl = this.storageConfig.upload.getUrl || this.providerUrl + '/bzz:/'; this.getUrl = this.storageConfig.upload.getUrl || this.providerUrl + '/bzz:/';
if (!this.isSwarmEnabledInTheConfig()) {
return;
}
this.bzz = new Web3Bzz(this.providerUrl); this.bzz = new Web3Bzz(this.providerUrl);
this.setServiceCheck(); this.setServiceCheck();
@ -41,10 +45,6 @@ class Swarm {
setServiceCheck() { setServiceCheck() {
let self = this; let self = this;
if (!this.isSwarmEnabledInTheConfig()) {
return;
}
this.events.on('check:backOnline:Swarm', function () { this.events.on('check:backOnline:Swarm', function () {
self.logger.info(__('Swarm node detected...')); self.logger.info(__('Swarm node detected...'));
}); });
@ -73,10 +73,6 @@ class Swarm {
} }
addProviderToEmbarkJS() { addProviderToEmbarkJS() {
if (!this.isSwarmEnabledInTheConfig()) {
return;
}
let code = ""; let code = "";
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString(); code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
code += "\nEmbarkJS.Storage.registerProvider('swarm', __embarkSwarm);"; code += "\nEmbarkJS.Storage.registerProvider('swarm', __embarkSwarm);";