pool: fix spv.

This commit is contained in:
Christopher Jeffrey 2017-01-20 19:17:03 -08:00
parent 08b41a2dc4
commit 7a5f4a1928
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1830,7 +1830,7 @@ Pool.prototype._handleTX = co(function* handleTX(peer, packet) {
if (peer.merkleBlock.hasTX(tx)) {
peer.merkleBlock.addTX(tx);
if (--peer.merkleMatches === 0) {
yield this.addBlock(peer, peer.merkleBlock);
yield this._addBlock(peer, peer.merkleBlock);
peer.merkleTime = -1;
peer.merkleBlock = null;
peer.merkleMatches = 0;
@ -1993,6 +1993,22 @@ Pool.prototype.handleFilterClear = co(function* handleFilterClear(peer, packet)
*/
Pool.prototype.handleMerkleBlock = co(function* handleMerkleBlock(peer, packet) {
var unlock = yield this.locker.lock();
try {
return yield this._handleMerkleBlock(peer, packet);
} finally {
unlock();
}
});
/**
* Handle `merkleblock` packet (without a lock).
* @private
* @param {Peer} peer
* @param {MerkleBlockPacket} block
*/
Pool.prototype._handleMerkleBlock = co(function* handleMerkleBlock(peer, packet) {
var block = packet.block;
var hash = block.hash('hex');
@ -2033,7 +2049,7 @@ Pool.prototype.handleMerkleBlock = co(function* handleMerkleBlock(peer, packet)
}
if (block.matches.length === 0) {
yield this.addBlock(peer, block);
yield this._addBlock(peer, block);
return;
}