mirror of https://github.com/embarklabs/embark.git
Merge pull request #476 from embark-framework/fix_events_limit_issue
fix events limit issue
This commit is contained in:
commit
0282e7d71c
|
@ -1,5 +1,6 @@
|
||||||
let utils = require('../../utils/utils.js');
|
let utils = require('../../utils/utils.js');
|
||||||
let fs = require('../../core/fs.js');
|
let fs = require('../../core/fs.js');
|
||||||
|
let Web3 = require('web3');
|
||||||
|
|
||||||
class Whisper {
|
class Whisper {
|
||||||
|
|
||||||
|
@ -8,18 +9,27 @@ class Whisper {
|
||||||
this.events = embark.events;
|
this.events = embark.events;
|
||||||
this.communicationConfig = embark.config.communicationConfig;
|
this.communicationConfig = embark.config.communicationConfig;
|
||||||
this.addCheck = options.addCheck;
|
this.addCheck = options.addCheck;
|
||||||
// TODO: this should not be needed and should be deducted from the config instead
|
this.web3 = new Web3();
|
||||||
this.web3 = options.web3;
|
|
||||||
this.embark = embark;
|
this.embark = embark;
|
||||||
|
|
||||||
|
this.connectToProvider();
|
||||||
this.setServiceCheck();
|
this.setServiceCheck();
|
||||||
this.addWhisperToEmbarkJS();
|
this.addWhisperToEmbarkJS();
|
||||||
this.addSetProvider();
|
this.addSetProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connectToProvider() {
|
||||||
|
let {host, port} = this.communicationConfig.connection;
|
||||||
|
let web3Endpoint = 'ws://' + host + ':' + port;
|
||||||
|
this.web3.setProvider(new Web3.providers.WebsocketProvider(web3Endpoint, {headers: {Origin: "http://localhost:8000"}}));
|
||||||
|
}
|
||||||
|
|
||||||
setServiceCheck() {
|
setServiceCheck() {
|
||||||
const self = this;
|
const self = this;
|
||||||
self.addCheck('Whisper', function (cb) {
|
self.addCheck('Whisper', function (cb) {
|
||||||
|
if (!self.web3.currentProvider || self.web3.currentProvider.connection.readyState !== 1) {
|
||||||
|
return self.connectToProvider();
|
||||||
|
}
|
||||||
self.web3.shh.getVersion(function (err, version) {
|
self.web3.shh.getVersion(function (err, version) {
|
||||||
if (err || version == "2") {
|
if (err || version == "2") {
|
||||||
return cb({name: 'Whisper', status: 'off'});
|
return cb({name: 'Whisper', status: 'off'});
|
||||||
|
|
Loading…
Reference in New Issue