diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index e235978a..5dc6c968 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -354,6 +354,7 @@ Pool.prototype._handleBlock = function _handleBlock(block, peer) { if (!this.options.fullNode) return; + // Emulate bip37 - emit all the "watched" txs if (this.listeners('watched').length > 0) { utils.nextTick(function() { block.txs.forEach(function(tx) { @@ -363,8 +364,6 @@ Pool.prototype._handleBlock = function _handleBlock(block, peer) { }); } - backoff = 0; - this._response(block); hash = block.hash('hex'); @@ -378,12 +377,18 @@ Pool.prototype._handleBlock = function _handleBlock(block, peer) { this.emit('_block', block, peer); if (this.chain.hasOrphan(block)) { - peer.loadBlocks(this.chain.locatorHashes(), this.chain.getOrphanRoot(block)); + // Resolve orphan chain + peer.loadBlocks( + this.chain.locatorHashes(), + this.chain.getOrphanRoot(block) + ); + // Emit our orphan if it is new if (!orphan) this.emit('orphan', block, peer); return; } + // Do not emit if nothing was added to the chain if (this.chain.size() === size) return;