Updated online/offline event checks so they are run during initialisation.

Changed the online event to `once` and set it to be bound every time the node goes offline.

The above changes handle the case where:
1) `embark run` runs and starts geth.
2) geth is killed manually
3) `embark blockchain` is run in separate process to restart geth
4) the `embark run` process detects this change and restarts the web3 provider and recompiles/deploys/builds

Every time `embark blochain` is restarted, an error is appended and all are emitted from the `eth-block-tracker`. This is a bug but can't figure out where it originates. The downside is that if, for example, `embark blockchain` is restarted 4 times, there will be 4 errors emitted from the `eth-block-tracker`. Because of this, errors emitted from `eth-block-tracker` have been reduced to trace to avoid clogging the logs.
This commit is contained in:
emizzle 2018-06-26 12:59:14 +10:00 committed by Pascal Precht
parent 80e323bdd3
commit 86480440b1
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 0 additions and 8 deletions

View File

@ -235,14 +235,6 @@ class BlockchainConnector {
if (err && err !== NO_NODE) {
return cb(err);
}
else if ((statusObj && statusObj.status === 'off') || err === NO_NODE){
self.provider.stop();
self.events.on('check:backOnline:Ethereum', () => {
self.provider.startWeb3Provider(() => {
self.logger.trace('web3 provider restarted after ethereum node came back online');
});
});
}
cb(statusObj);
});
}, 5000, 'off');