From 05c6cd77399b92affe33ff62715ea830b4abe456 Mon Sep 17 00:00:00 2001 From: tripathyr Date: Tue, 25 May 2021 11:07:56 +0530 Subject: [PATCH] Fixed header existence conditions --- lib/services/block/index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/services/block/index.js b/lib/services/block/index.js index ba6a1aac..4045b5c2 100644 --- a/lib/services/block/index.js +++ b/lib/services/block/index.js @@ -252,9 +252,9 @@ BlockService.prototype._resetTip = function(callback) { return callback(err); } - if (!_block) { + if (!_block) { log.debug('Block Service: block: ' + header.hash + ' was not found, proceeding to older blocks.'); - } + } block = _block; header = headers.getIndex(--height); @@ -721,16 +721,18 @@ BlockService.prototype._findLatestValidBlockHeader = function(callback) { // if some joker mines a block using an orphan block as its prev block, then the effect of this will be // us detecting a reorg, but not actually reorging anything // FLOSight Error Correction from RanchiMall 17th May 2021. removed the unhandled assert and replaced by looging of error + if (typeof header !== 'undefined') { if (header == false) { log.error('Block Service: we could not locate any of our recent block hashes in the header service ' + 'index. Perhaps our header service sync\'ed to the wrong chain?'); } + } // assert(header, 'Block Service: we could not locate any of our recent block hashes in the header service ' + 'index. Perhaps our header service sync\'ed to the wrong chain?'); - if (typeof header.height !== 'undefined') { - if (header.height > self._tip.height) { - log.error('Block Service: we found a common ancestor header whose ' + 'height was greater than our current tip. This should be impossible.'); - } + if (typeof header.height !== 'undefined') { + if (header.height > self._tip.height) { + log.error('Block Service: we found a common ancestor header whose ' + 'height was greater than our current tip. This should be impossible.'); + } // assert(header.height <= self._tip.height, 'Block Service: we found a common ancestor header whose ' + 'height was greater than our current tip. This should be impossible.'); - } + } callback(null, header); });