peer: fix serving broadcasted txs.

This commit is contained in:
Christopher Jeffrey 2016-09-16 00:03:55 -07:00
parent 9dd863d9f2
commit 7aa2ecb24b
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 13 additions and 11 deletions

View File

@ -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

View File

@ -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);