From 7aa2ecb24bc3dcc80cbc650b17be657c867bee9e Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 16 Sep 2016 00:03:55 -0700 Subject: [PATCH] peer: fix serving broadcasted txs. --- lib/net/peer.js | 22 ++++++++++++---------- lib/node/fullnode.js | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/net/peer.js b/lib/net/peer.js index c5794907..2afd387d 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -1446,8 +1446,16 @@ Peer.prototype._getItem = function _getItem(item, callback) { entry.ack(this); - if (entry.msg) - return callback(null, entry.msg); + if (entry.msg) { + if (item.isTX()) { + if (entry.type === constants.inv.TX) + return callback(null, entry.msg); + } else { + if (entry.type === constants.inv.BLOCK) + return callback(null, entry.msg); + } + return callback(); + } } if (this.options.selfish) @@ -1456,7 +1464,7 @@ Peer.prototype._getItem = function _getItem(item, callback) { if (item.isTX()) { if (!this.mempool) return callback(); - return callback(null, this.mempool.getEntry(item.hash)); + return callback(null, this.mempool.getTX(item.hash)); } if (this.chain.db.options.spv) @@ -1508,7 +1516,7 @@ Peer.prototype._handleGetData = function _handleGetData(items) { } if (item.isTX()) { - tx = entry.tx; + tx = entry; // Coinbases are an insta-ban from any node. // This should technically never happen, but @@ -1520,12 +1528,6 @@ Peer.prototype._handleGetData = function _handleGetData(items) { return next(); } - // Fallback in case fee filter fails in `announce`. - if (self.feeRate !== -1) { - if (entry.getRate() < self.feeRate) - return next(); - } - if (item.hasWitness()) self.write(self.framer.witnessTX(tx)); else diff --git a/lib/node/fullnode.js b/lib/node/fullnode.js index 729f935b..c5d2f60c 100644 --- a/lib/node/fullnode.js +++ b/lib/node/fullnode.js @@ -333,7 +333,7 @@ Fullnode.prototype.sendTX = function sendTX(tx, wait, callback) { if (err) { if (err.type === 'VerifyError') { self._error(err); - self.logger.warning('Verification failed for tx: %.', tx.rhash); + self.logger.warning('Verification failed for tx: %s.', tx.rhash); self.logger.warning('Attempting to broadcast anyway...'); if (!wait) { self.pool.broadcast(tx);