diff --git a/lib/bcoin/chain.js b/lib/bcoin/chain.js index e7dc33d8..2689f20c 100644 --- a/lib/bcoin/chain.js +++ b/lib/bcoin/chain.js @@ -2095,7 +2095,7 @@ Chain.prototype.retarget = function retarget(prev, first) { }; /** - * Find a locator. Analagous to bitcoind's `FindForkInMainChain()`. + * Find a locator. Analagous to bitcoind's `FindForkInGlobalIndex()`. * @param {Hash[]} locator - Hashes. * @param {Function} callback - Returns [Error, {@link Hash}] (the * hash of the latest known block). diff --git a/lib/bcoin/peer.js b/lib/bcoin/peer.js index 87b56aa0..9943eb9b 100644 --- a/lib/bcoin/peer.js +++ b/lib/bcoin/peer.js @@ -1222,11 +1222,14 @@ Peer.prototype._handleGetData = function _handleGetData(items) { return done(); } + // Hit the broadcast queue first. for (i = 0; i < items.length; i++) { item = items[i]; entry = this.pool.inv.map[item.hash]; witness = (item.type & constants.WITNESS_MASK) !== 0; + // If the item isn't present, queue it up + // to be checked in the mempool or chain. if (!entry) { check.push(item); continue; @@ -1246,6 +1249,10 @@ Peer.prototype._handleGetData = function _handleGetData(items) { witness ? 'witness' : 'normal', this.hostname); + // Try to send the data. + // If the item was announce-only (i.e. the data + // isn't actually contained in the broadcast + // item), check this on the mempool/chain. if (!entry.send(this, witness)) check.push(item); } @@ -1253,6 +1260,8 @@ Peer.prototype._handleGetData = function _handleGetData(items) { if (this.pool.options.selfish) return done(); + // Item wasn't found in broadcast queue. + // Check the mempool and chain. utils.forEachSerial(check, function(item, next) { var type = item.type & ~constants.WITNESS_MASK; var witness = (item.type & constants.WITNESS_MASK) !== 0; diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index d6a65de8..24f70988 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -2254,6 +2254,8 @@ BroadcastItem.prototype.send = function send(peer, witness) { } if (this.type === constants.inv.TX) { + // Failsafe - we never want to relay coinbases. + // They are an insta-ban from any bitcoind node. if (this.msg.isCoinbase()) { peer.write(peer.framer.notFound([this])); bcoin.debug('Failsafe: tried to relay a coinbase.');