Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 2,033 Lines • ▼ Show 20 Lines | if (send && pindex->nStatus.hasData()) { | ||||
connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::INV, vInv)); | connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::INV, vInv)); | ||||
pfrom.hashContinue = BlockHash(); | pfrom.hashContinue = BlockHash(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
//! Determine whether or not a peer can request a transaction, and return it (or | //! Determine whether or not a peer can request a transaction, and return it (or | ||||
//! nullptr if not found or not allowed). | //! nullptr if not found or not allowed). | ||||
CTransactionRef static FindTxForGetData(const CNode &peer, const TxId &txid, | static CTransactionRef FindTxForGetData(const CTxMemPool &mempool, | ||||
const CNode &peer, const TxId &txid, | |||||
const std::chrono::seconds mempool_req, | const std::chrono::seconds mempool_req, | ||||
const std::chrono::seconds now) | const std::chrono::seconds now) | ||||
LOCKS_EXCLUDED(cs_main) { | LOCKS_EXCLUDED(cs_main) { | ||||
auto txinfo = g_mempool.info(txid); | auto txinfo = mempool.info(txid); | ||||
if (txinfo.tx) { | if (txinfo.tx) { | ||||
// If a TX could have been INVed in reply to a MEMPOOL request, | // If a TX could have been INVed in reply to a MEMPOOL request, | ||||
// or is older than UNCONDITIONAL_RELAY_DELAY, permit the request | // or is older than UNCONDITIONAL_RELAY_DELAY, permit the request | ||||
// unconditionally. | // unconditionally. | ||||
if ((mempool_req.count() && txinfo.m_time <= mempool_req) || | if ((mempool_req.count() && txinfo.m_time <= mempool_req) || | ||||
txinfo.m_time <= now - UNCONDITIONAL_RELAY_DELAY) { | txinfo.m_time <= now - UNCONDITIONAL_RELAY_DELAY) { | ||||
return std::move(txinfo.tx); | return std::move(txinfo.tx); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | while (it != pfrom.vRecvGetData.end()) { | ||||
if (pfrom.m_tx_relay == nullptr) { | if (pfrom.m_tx_relay == nullptr) { | ||||
// Ignore GETDATA requests for transactions from blocks-only | // Ignore GETDATA requests for transactions from blocks-only | ||||
// peers. | // peers. | ||||
continue; | continue; | ||||
} | } | ||||
const TxId txid(inv.hash); | const TxId txid(inv.hash); | ||||
CTransactionRef tx = | CTransactionRef tx = | ||||
FindTxForGetData(pfrom, txid, mempool_req, now); | FindTxForGetData(mempool, pfrom, txid, mempool_req, now); | ||||
if (tx) { | if (tx) { | ||||
int nSendFlags = 0; | int nSendFlags = 0; | ||||
connman.PushMessage( | connman.PushMessage( | ||||
&pfrom, msgMaker.Make(nSendFlags, NetMsgType::TX, *tx)); | &pfrom, msgMaker.Make(nSendFlags, NetMsgType::TX, *tx)); | ||||
mempool.RemoveUnbroadcastTx(txid); | mempool.RemoveUnbroadcastTx(txid); | ||||
// As we're going to send tx, make sure its unconfirmed parents | // As we're going to send tx, make sure its unconfirmed parents | ||||
// are made requestable. | // are made requestable. | ||||
for (const auto &txin : tx->vin) { | for (const auto &txin : tx->vin) { | ||||
▲ Show 20 Lines • Show All 3,715 Lines • Show Last 20 Lines |