pool: do not reset chain when checkpoints=false.

This commit is contained in:
Christopher Jeffrey 2017-02-02 17:55:38 -08:00
parent 69b442a318
commit f20aae676a
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 7 additions and 6 deletions

View File

@ -1739,9 +1739,9 @@ Chain.prototype._getLocator = co(function* getLocator(start) {
entry = this.tip; entry = this.tip;
} }
hash = entry.hash;
height = entry.height; height = entry.height;
main = yield entry.isMainChain(); main = yield entry.isMainChain();
hash = entry.hash;
while (hash) { while (hash) {
hashes.push(hash); hashes.push(hash);
@ -1749,7 +1749,7 @@ Chain.prototype._getLocator = co(function* getLocator(start) {
if (height === 0) if (height === 0)
break; break;
height = Math.max(height - step, 0); height = Math.max(0, height - step);
if (hashes.length > 10) if (hashes.length > 10)
step *= 2; step *= 2;

View File

@ -162,7 +162,8 @@ Pool.prototype._init = function _init() {
}); });
this.chain.on('reset', function() { this.chain.on('reset', function() {
self.resetChain(); if (self.checkpoints)
self.resetChain();
self.forceSync(); self.forceSync();
}); });
@ -247,8 +248,7 @@ Pool.prototype.resetChain = function resetChain() {
this.headerChain.push(new HeaderEntry(tip.hash, tip.height)); this.headerChain.push(new HeaderEntry(tip.hash, tip.height));
this.logger.info( this.logger.info(
'Initialized header chain to height %d (checkpoint=%s).', 'Initialized header chain to height %d (checkpoint=%s).',
tip.height, tip.height, util.revHex(this.headerTip.hash));
this.headerTip.hash);
} }
}; };
@ -1143,7 +1143,8 @@ Pool.prototype.handleClose = co(function* handleClose(peer, connected) {
if (loader) { if (loader) {
this.logger.info('Removed loader peer (%s).', peer.hostname()); this.logger.info('Removed loader peer (%s).', peer.hostname());
this.resetChain(); if (this.checkpoints)
this.resetChain();
} }
this.nonces.remove(peer.hostname()); this.nonces.remove(peer.hostname());