pool: do not reset chain when checkpoints=false.
This commit is contained in:
parent
69b442a318
commit
f20aae676a
@ -1739,9 +1739,9 @@ Chain.prototype._getLocator = co(function* getLocator(start) {
|
||||
entry = this.tip;
|
||||
}
|
||||
|
||||
hash = entry.hash;
|
||||
height = entry.height;
|
||||
main = yield entry.isMainChain();
|
||||
hash = entry.hash;
|
||||
|
||||
while (hash) {
|
||||
hashes.push(hash);
|
||||
@ -1749,7 +1749,7 @@ Chain.prototype._getLocator = co(function* getLocator(start) {
|
||||
if (height === 0)
|
||||
break;
|
||||
|
||||
height = Math.max(height - step, 0);
|
||||
height = Math.max(0, height - step);
|
||||
|
||||
if (hashes.length > 10)
|
||||
step *= 2;
|
||||
|
||||
@ -162,7 +162,8 @@ Pool.prototype._init = function _init() {
|
||||
});
|
||||
|
||||
this.chain.on('reset', function() {
|
||||
self.resetChain();
|
||||
if (self.checkpoints)
|
||||
self.resetChain();
|
||||
self.forceSync();
|
||||
});
|
||||
|
||||
@ -247,8 +248,7 @@ Pool.prototype.resetChain = function resetChain() {
|
||||
this.headerChain.push(new HeaderEntry(tip.hash, tip.height));
|
||||
this.logger.info(
|
||||
'Initialized header chain to height %d (checkpoint=%s).',
|
||||
tip.height,
|
||||
this.headerTip.hash);
|
||||
tip.height, util.revHex(this.headerTip.hash));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1143,7 +1143,8 @@ Pool.prototype.handleClose = co(function* handleClose(peer, connected) {
|
||||
|
||||
if (loader) {
|
||||
this.logger.info('Removed loader peer (%s).', peer.hostname());
|
||||
this.resetChain();
|
||||
if (this.checkpoints)
|
||||
this.resetChain();
|
||||
}
|
||||
|
||||
this.nonces.remove(peer.hostname());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user