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.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"];

View File

@ -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);";