Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Check the error exists or not and then return with proper message #3924

Merged
merged 6 commits into from
Jul 9, 2019
17 changes: 12 additions & 5 deletions framework/src/modules/chain/submodules/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,21 +813,28 @@ __private.loadBlocksFromNetwork = function(cb) {
modules.blocks.process.loadBlocksFromNetwork(
(loadBlocksFromNetworkErr, lastValidBlock) => {
if (loadBlocksFromNetworkErr) {
library.logger.error(
loadBlocksFromNetworkErr instanceof Error
ishantiw marked this conversation as resolved.
Show resolved Hide resolved
? loadBlocksFromNetworkErr
: new Error(loadBlocksFromNetworkErr),
'Chain recovery failed after failing to load blocks from the network'
);
// If comparison failed and current consensus is low - perform chain recovery
if (modules.peers.isPoorConsensus()) {
library.logger.debug(
'Perform chain recovery due to poor consensus'
);
return modules.blocks.chain.recoverChain(recoveryError => {
if (recoveryError) {
waterCb(
`Chain recovery failed after failing to load blocks while network consensus was low. ${recoveryError}`
);
}
waterCb(
`Failed chain recovery after failing to load blocks while network consensus was low. ${recoveryError}`
`Chain recovery failed chain recovery after failing to load blocks ${loadBlocksFromNetworkErr}`
);
});
}
library.logger.error(
'Failed to process block from network',
loadBlocksFromNetworkErr
);
return waterCb(
`Failed to load blocks from the network. ${loadBlocksFromNetworkErr}`
);
Expand Down