fix(whisper): fix crash on using whisper with the simualtor

This commit is contained in:
Jonathan Rainville 2018-12-12 15:40:06 -05:00 committed by Iuri Matias
parent 89c9b1f0ef
commit 1461e95c39
1 changed files with 15 additions and 6 deletions

View File

@ -30,12 +30,21 @@ class Whisper {
this.connectToProvider(); this.connectToProvider();
this.events.request('processes:register', 'whisper', (cb) => { this.events.request('processes:register', 'whisper', (cb) => {
this.setServiceCheck(); this.web3.shh.getInfo((err) => {
this.addWhisperToEmbarkJS(); if (err) {
this.addSetProvider(); const message = err.message || err;
this.waitForWeb3Ready(() => { if (message.indexOf('not supported') > -1) {
this.registerAPICalls(); this.logger.error('Whisper is not supported on your node. Are you using the simulator?');
cb(); return this.logger.trace(message);
}
}
this.setServiceCheck();
this.addWhisperToEmbarkJS();
this.addSetProvider();
this.waitForWeb3Ready(() => {
this.registerAPICalls();
cb();
});
}); });
}); });