From c6317a268dddb8a90286152a45bcb73b7c88d83e Mon Sep 17 00:00:00 2001 From: ohryan Date: Thu, 16 Jul 2020 19:20:49 -0700 Subject: [PATCH] update invalidation stepping to use just the while loop and add missing await to assert check --- lib/blockchain/chain.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index 204fbb98..4e5f53e8 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -979,18 +979,14 @@ class Chain extends AsyncEmitter { tip.height - fork.height ); - // mark invalid_child from tip of fork to second block of fork - while (competitor.height > fork.height + 2) { + // 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) } - // mark invalid first block of fork - const previous = await this.getPrevious(competitor) - await this.invalidate(previous.hash) - // check - assert.equal(this.getPrevious(previous), fork, 'nlr invalidation down to the fork') + assert.equal(await this.getPrevious(competitor), fork, 'nlr invalidation down to the fork') return true }