From b8c788c207fcb17df9c61cf65b9fe283010c90aa Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 16 Jun 2017 00:13:29 -0700 Subject: [PATCH] chain: getLocator refactor. --- lib/blockchain/chain.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index cefcaf29..e5e6ba75 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -1867,12 +1867,9 @@ Chain.prototype._getLocator = co(function* getLocator(start) { height = entry.height; main = yield entry.isMainChain(); - while (hash) { - hashes.push(hash); - - if (height === 0) - break; + hashes.push(hash); + while (height > 0) { height -= step; if (height < 0) @@ -1885,11 +1882,14 @@ Chain.prototype._getLocator = co(function* getLocator(start) { // If we're on the main chain, we can // do a fast lookup of the hash. hash = yield this.db.getHash(height); + assert(hash); } else { entry = yield entry.getAncestor(height); assert(entry); hash = entry.hash; } + + hashes.push(hash); } return hashes;