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 {
|
||||
yield this.chain.add(block);
|
||||
} catch (err) {
|
||||
if (err.type !== 'VerifyError')
|
||||
throw err;
|
||||
|
||||
if (err.reason === 'bad-prevblk') {
|
||||
if (this.headersFirst) {
|
||||
peer.increaseBan(10);
|
||||
throw err;
|
||||
if (err.type === 'VerifyError') {
|
||||
if (err.reason === 'bad-prevblk') {
|
||||
if (this.headersFirst) {
|
||||
peer.increaseBan(10);
|
||||
this.emit('error', err);
|
||||
return;
|
||||
}
|
||||
this.logger.debug('Peer sent an orphan block. Resolving.');
|
||||
yield peer.resolveOrphan(null, hash);
|
||||
return;
|
||||
}
|
||||
this.logger.debug('Peer sent an orphan block. Resolving.');
|
||||
yield peer.resolveOrphan(null, hash);
|
||||
throw err;
|
||||
peer.reject(block, err.code, err.reason, err.score);
|
||||
this.emit('error', err);
|
||||
return;
|
||||
}
|
||||
|
||||
peer.reject(block, err.code, err.reason, err.score);
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
@ -1015,8 +1015,11 @@ Pool.prototype._handleTX = co(function* handleTX(peer, tx) {
|
||||
try {
|
||||
missing = yield this.mempool.addTX(tx);
|
||||
} catch (err) {
|
||||
if (err.type === 'VerifyError')
|
||||
if (err.type === 'VerifyError') {
|
||||
peer.reject(tx, err.code, err.reason, err.score);
|
||||
this.emit('error', err);
|
||||
return;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
@ -1605,7 +1608,6 @@ Pool.prototype.watchOutpoint = function watchOutpoint(outpoint) {
|
||||
* Queue a `getdata` request to be sent.
|
||||
* @param {Peer} peer
|
||||
* @param {Hash[]} hashes
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
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
|
||||
* in the mempool before requesting.
|
||||
* Queue a `getdata` request to be sent.
|
||||
* @param {Peer} peer
|
||||
* @param {Hash[]} hashes
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
|
||||
Pool.prototype.getTX = function getTX(peer, hashes) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user