mirror of https://github.com/embarklabs/embark.git
move whisper to a module
This commit is contained in:
parent
e833ebd019
commit
310712567f
|
@ -294,7 +294,6 @@ class CodeGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code += "\n" + fs.readFileSync(fs.embarkPath('js/embarkjs/whisper.js')).toString();
|
|
||||||
//code += "\n" + fs.readFileSync(fs.embarkPath('js/embarkjs/orbit.js')).toString();
|
//code += "\n" + fs.readFileSync(fs.embarkPath('js/embarkjs/orbit.js')).toString();
|
||||||
|
|
||||||
code += this.generateCommunicationInitialization(true);
|
code += this.generateCommunicationInitialization(true);
|
||||||
|
|
|
@ -200,14 +200,10 @@ class Engine {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
self.servicesMonitor.addCheck('Whisper', function (cb) {
|
this.registerModule('whisper', {
|
||||||
self.web3.version.getWhisper(function (err, version) {
|
addCheck: this.servicesMonitor.addCheck.bind(this.servicesMonitor),
|
||||||
if (err) {
|
communicationConfig: this.config.communicationConfig,
|
||||||
return cb({name: 'Whisper', status: 'off'});
|
web3: this.web3
|
||||||
} else {
|
|
||||||
return cb({name: 'Whisper (version ' + version + ')', status: 'on'});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
let utils = require('../../utils/utils.js');
|
||||||
|
let fs = require('../../core/fs.js');
|
||||||
|
|
||||||
|
class Whisper {
|
||||||
|
|
||||||
|
constructor(embark, options) {
|
||||||
|
this.logger = embark.logger;
|
||||||
|
this.events = embark.events;
|
||||||
|
this.communicationConfig = options.communicationConfig;
|
||||||
|
this.addCheck = options.addCheck;
|
||||||
|
this.web3 = options.web3;
|
||||||
|
this.embark = embark;
|
||||||
|
|
||||||
|
this.setServiceCheck();
|
||||||
|
this.addWhisperToEmbarkJS();
|
||||||
|
}
|
||||||
|
|
||||||
|
setServiceCheck() {
|
||||||
|
const self = this;
|
||||||
|
self.addCheck('Whisper', function (cb) {
|
||||||
|
self.web3.version.getWhisper(function (err, version) {
|
||||||
|
if (err) {
|
||||||
|
return cb({name: 'Whisper', status: 'off'});
|
||||||
|
} else {
|
||||||
|
return cb({name: 'Whisper (version ' + version + ')', status: 'on'});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
addWhisperToEmbarkJS() {
|
||||||
|
if (this.communicationConfig === {}) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(this.communicationConfig.provider !== 'whisper' || this.communicationConfig.enabled !== true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let code = "";
|
||||||
|
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
|
||||||
|
code += "\nEmbarkJS.Storage.registerProvider('ipfs', __embarkWhisper);";
|
||||||
|
|
||||||
|
this.embark.addCodeToEmbarkJS(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Whisper;
|
Loading…
Reference in New Issue