pull loop variable outside for reassignment
This commit is contained in:
parent
c6317a268d
commit
36671d02ed
@ -969,24 +969,27 @@ class Chain extends AsyncEmitter {
|
|||||||
if (tip.height - fork.height >= this.network.nlrLimit) {
|
if (tip.height - fork.height >= this.network.nlrLimit) {
|
||||||
if (this.network.nlrLimit !== 0) {
|
if (this.network.nlrLimit !== 0) {
|
||||||
this.logger.warning(
|
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.hash,
|
||||||
tip.height,
|
tip.height,
|
||||||
competitor.hash,
|
competitor.hash,
|
||||||
competitor.height,
|
competitor.height,
|
||||||
fork.hash,
|
fork.hash,
|
||||||
fork.height,
|
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
|
// mark invalid_child from tip of fork to first block of fork
|
||||||
while (competitor.height !== fork.height + 1) {
|
while (indexWalk.height !== fork.height + 1) {
|
||||||
const previous = await this.getPrevious(competitor)
|
indexWalk = await this.getPrevious(indexWalk)
|
||||||
await this.invalidate(previous.hash)
|
await this.invalidate(indexWalk.hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check
|
// 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
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user