pool: disable checkpoints properly. rename prop for consistency.
This commit is contained in:
parent
e7413aabb7
commit
c44fc3bcef
@ -110,7 +110,7 @@ function Pool(options) {
|
||||
this.pendingFilter = null;
|
||||
this.pendingRefill = null;
|
||||
|
||||
this.headersFirst = false;
|
||||
this.checkpoints = false;
|
||||
this.headerChain = new List();
|
||||
this.headerNext = null;
|
||||
this.headerTip = null;
|
||||
@ -233,13 +233,15 @@ Pool.prototype.resetChain = function resetChain() {
|
||||
if (!this.options.checkpoints)
|
||||
return;
|
||||
|
||||
this.headersFirst = false;
|
||||
this.checkpoints = false;
|
||||
this.chain.checkpoints = false;
|
||||
this.headerTip = null;
|
||||
this.headerChain.reset();
|
||||
this.headerNext = null;
|
||||
|
||||
if (tip.height < this.network.lastCheckpoint) {
|
||||
this.headersFirst = true;
|
||||
this.checkpoints = true;
|
||||
this.chain.checkpoints = true;
|
||||
this.headerTip = this.getNextTip(tip.height);
|
||||
this.headerChain.push(new HeaderEntry(tip.hash, tip.height));
|
||||
this.logger.info(
|
||||
@ -364,7 +366,8 @@ Pool.prototype._disconnect = co(function* disconnect() {
|
||||
this.pendingRefill = null;
|
||||
}
|
||||
|
||||
this.headersFirst = false;
|
||||
this.checkpoints = false;
|
||||
this.chain.checkpoints = false;
|
||||
this.headerTip = null;
|
||||
this.headerChain.reset();
|
||||
this.headerNext = null;
|
||||
@ -616,11 +619,6 @@ Pool.prototype.sendSync = co(function* sendSync(peer) {
|
||||
peer.syncing = true;
|
||||
peer.blockTime = util.ms();
|
||||
|
||||
if (this.headersFirst) {
|
||||
peer.sendGetHeaders([tip.hash], this.headerTip.hash);
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
locator = yield this.chain.getLocator();
|
||||
} catch (e) {
|
||||
@ -628,6 +626,11 @@ Pool.prototype.sendSync = co(function* sendSync(peer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.checkpoints) {
|
||||
peer.sendGetHeaders(locator, this.headerTip.hash);
|
||||
return true;
|
||||
}
|
||||
|
||||
peer.sendGetBlocks(locator);
|
||||
|
||||
return true;
|
||||
@ -1396,7 +1399,7 @@ Pool.prototype.handleBlockInv = co(function* handleBlockInv(peer, hashes) {
|
||||
return;
|
||||
|
||||
// Request headers instead.
|
||||
if (this.headersFirst)
|
||||
if (this.checkpoints)
|
||||
return;
|
||||
|
||||
this.logger.debug(
|
||||
@ -1751,7 +1754,7 @@ Pool.prototype._handleHeaders = co(function* handleHeaders(peer, packet) {
|
||||
var checkpoint = false;
|
||||
var i, header, hash, height, last, node;
|
||||
|
||||
if (!this.headersFirst)
|
||||
if (!this.checkpoints)
|
||||
return;
|
||||
|
||||
if (!this.syncing)
|
||||
@ -1926,7 +1929,7 @@ Pool.prototype._addBlock = co(function* addBlock(peer, block) {
|
||||
} catch (err) {
|
||||
if (err.type === 'VerifyError') {
|
||||
if (err.reason === 'bad-prevblk') {
|
||||
if (this.headersFirst) {
|
||||
if (this.checkpoints) {
|
||||
peer.increaseBan(10);
|
||||
this.emit('error', err, peer);
|
||||
return;
|
||||
@ -1958,7 +1961,7 @@ Pool.prototype._addBlock = co(function* addBlock(peer, block) {
|
||||
Pool.prototype.resolveChain = co(function* resolveChain(peer, hash) {
|
||||
var node = this.headerChain.head;
|
||||
|
||||
if (!this.headersFirst)
|
||||
if (!this.checkpoints)
|
||||
return;
|
||||
|
||||
if (!peer.loader)
|
||||
@ -2016,10 +2019,10 @@ Pool.prototype.resolveChain = co(function* resolveChain(peer, hash) {
|
||||
*/
|
||||
|
||||
Pool.prototype.switchSync = co(function* switchSync(peer, hash) {
|
||||
assert(this.headersFirst);
|
||||
assert(this.checkpoints);
|
||||
|
||||
this.checkpoints = false;
|
||||
this.chain.checkpoints = false;
|
||||
this.headersFirst = false;
|
||||
this.headerTip = null;
|
||||
this.headerChain.reset();
|
||||
this.headerNext = null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user