@@ -1609,8 +1609,16 @@ void static ProcessGetBlockData(CNode* pfrom, const CChainParams& chainparams, c
1609
1609
}
1610
1610
1611
1611
// ! Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed).
1612
- CTransactionRef static FindTxForGetData (const uint256& txid, const std::chrono::seconds mempool_req, const std::chrono::seconds longlived_mempool_time) LOCKS_EXCLUDED(cs_main)
1612
+ CTransactionRef static FindTxForGetData (CNode* peer, const uint256& txid, const std::chrono::seconds mempool_req, const std::chrono::seconds longlived_mempool_time) LOCKS_EXCLUDED(cs_main)
1613
1613
{
1614
+ // Check if the requested transaction is so recent that we're just
1615
+ // about to announce it to the peer; if so, they certainly shouldn't
1616
+ // know we already have it.
1617
+ {
1618
+ LOCK (peer->m_tx_relay ->cs_tx_inventory );
1619
+ if (peer->m_tx_relay ->setInventoryTxToSend .count (txid)) return {};
1620
+ }
1621
+
1614
1622
{
1615
1623
LOCK (cs_main);
1616
1624
// Look up transaction in relay pool
@@ -1661,7 +1669,7 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
1661
1669
continue ;
1662
1670
}
1663
1671
1664
- CTransactionRef tx = FindTxForGetData (inv.hash , mempool_req, longlived_mempool_time);
1672
+ CTransactionRef tx = FindTxForGetData (pfrom, inv.hash , mempool_req, longlived_mempool_time);
1665
1673
if (tx) {
1666
1674
int nSendFlags = (inv.type == MSG_TX ? SERIALIZE_TRANSACTION_NO_WITNESS : 0 );
1667
1675
connman->PushMessage (pfrom, msgMaker.Make (nSendFlags, NetMsgType::TX, *tx));
0 commit comments