pull loop variable outside for reassignment

This commit is contained in:
ohryan 2020-07-17 20:03:07 -07:00
parent c6317a268d
commit 36671d02ed

View File

@ -969,24 +969,27 @@ class Chain extends AsyncEmitter {
if (tip.height - fork.height >= this.network.nlrLimit) {
if (this.network.nlrLimit !== 0) {
this.logger.warning(
'NLR Activated. Preventing reorganization: current=%h(%d) competitor=%h(%d) fork=%h(%d) reorg_size=%d',
'NLR Activated. Preventing reorganization: current=%h(%d) competitor=%h(%d) fork=%h(%d) reorg_size=%d nlr=%d',
tip.hash,
tip.height,
competitor.hash,
competitor.height,
fork.hash,
fork.height,
tip.height - fork.height
tip.height - fork.height,
this.network.nlrLimit
);
let indexWalk = competitor
// mark invalid_child from tip of fork to first block of fork
while (competitor.height !== fork.height + 1) {
const previous = await this.getPrevious(competitor)
await this.invalidate(previous.hash)
while (indexWalk.height !== fork.height + 1) {
indexWalk = await this.getPrevious(indexWalk)
await this.invalidate(indexWalk.hash)
}
// check
assert.equal(await this.getPrevious(competitor), fork, 'nlr invalidation down to the fork')
assert.equal(await this.getPrevious(indexWalk), fork, 'nlr invalidation down to the fork')
return true
}