chain: getLocator refactor.
This commit is contained in:
parent
fb8b9fac2b
commit
b8c788c207
@ -1867,12 +1867,9 @@ Chain.prototype._getLocator = co(function* getLocator(start) {
|
|||||||
height = entry.height;
|
height = entry.height;
|
||||||
main = yield entry.isMainChain();
|
main = yield entry.isMainChain();
|
||||||
|
|
||||||
while (hash) {
|
hashes.push(hash);
|
||||||
hashes.push(hash);
|
|
||||||
|
|
||||||
if (height === 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
while (height > 0) {
|
||||||
height -= step;
|
height -= step;
|
||||||
|
|
||||||
if (height < 0)
|
if (height < 0)
|
||||||
@ -1885,11 +1882,14 @@ Chain.prototype._getLocator = co(function* getLocator(start) {
|
|||||||
// If we're on the main chain, we can
|
// If we're on the main chain, we can
|
||||||
// do a fast lookup of the hash.
|
// do a fast lookup of the hash.
|
||||||
hash = yield this.db.getHash(height);
|
hash = yield this.db.getHash(height);
|
||||||
|
assert(hash);
|
||||||
} else {
|
} else {
|
||||||
entry = yield entry.getAncestor(height);
|
entry = yield entry.getAncestor(height);
|
||||||
assert(entry);
|
assert(entry);
|
||||||
hash = entry.hash;
|
hash = entry.hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hashes.push(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hashes;
|
return hashes;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user