Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,999 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
//! 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, | CTransactionRef static FindTxForGetData(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) { | ||||
// Check if the requested transaction is so recent that we're just | |||||
// about to announce it to the peer; if so, they certainly shouldn't | |||||
// know we already have it. | |||||
{ | |||||
LOCK(peer.m_tx_relay->cs_tx_inventory); | |||||
if (peer.m_tx_relay->setInventoryTxToSend.count(txid)) { | |||||
return {}; | |||||
} | |||||
} | |||||
auto txinfo = g_mempool.info(txid); | auto txinfo = g_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) { | ||||
▲ Show 20 Lines • Show All 3,603 Lines • Show Last 20 Lines |