pool: fix verify error handling.
This commit is contained in:
parent
0a756aba34
commit
8cd951c994
@ -880,21 +880,21 @@ Pool.prototype._handleBlock = co(function* handleBlock(peer, block) {
|
|||||||
try {
|
try {
|
||||||
yield this.chain.add(block);
|
yield this.chain.add(block);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.type !== 'VerifyError')
|
if (err.type === 'VerifyError') {
|
||||||
throw err;
|
if (err.reason === 'bad-prevblk') {
|
||||||
|
if (this.headersFirst) {
|
||||||
if (err.reason === 'bad-prevblk') {
|
peer.increaseBan(10);
|
||||||
if (this.headersFirst) {
|
this.emit('error', err);
|
||||||
peer.increaseBan(10);
|
return;
|
||||||
throw err;
|
}
|
||||||
|
this.logger.debug('Peer sent an orphan block. Resolving.');
|
||||||
|
yield peer.resolveOrphan(null, hash);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
this.logger.debug('Peer sent an orphan block. Resolving.');
|
peer.reject(block, err.code, err.reason, err.score);
|
||||||
yield peer.resolveOrphan(null, hash);
|
this.emit('error', err);
|
||||||
throw err;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
peer.reject(block, err.code, err.reason, err.score);
|
|
||||||
|
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1015,8 +1015,11 @@ Pool.prototype._handleTX = co(function* handleTX(peer, tx) {
|
|||||||
try {
|
try {
|
||||||
missing = yield this.mempool.addTX(tx);
|
missing = yield this.mempool.addTX(tx);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.type === 'VerifyError')
|
if (err.type === 'VerifyError') {
|
||||||
peer.reject(tx, err.code, err.reason, err.score);
|
peer.reject(tx, err.code, err.reason, err.score);
|
||||||
|
this.emit('error', err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1605,7 +1608,6 @@ Pool.prototype.watchOutpoint = function watchOutpoint(outpoint) {
|
|||||||
* Queue a `getdata` request to be sent.
|
* Queue a `getdata` request to be sent.
|
||||||
* @param {Peer} peer
|
* @param {Peer} peer
|
||||||
* @param {Hash[]} hashes
|
* @param {Hash[]} hashes
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Pool.prototype.getBlock = function getBlock(peer, hashes) {
|
Pool.prototype.getBlock = function getBlock(peer, hashes) {
|
||||||
@ -1646,11 +1648,9 @@ Pool.prototype.getBlock = function getBlock(peer, hashes) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue a `getdata` request to be sent. Checks existence
|
* Queue a `getdata` request to be sent.
|
||||||
* in the mempool before requesting.
|
|
||||||
* @param {Peer} peer
|
* @param {Peer} peer
|
||||||
* @param {Hash[]} hashes
|
* @param {Hash[]} hashes
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Pool.prototype.getTX = function getTX(peer, hashes) {
|
Pool.prototype.getTX = function getTX(peer, hashes) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user