@@ -1609,8 +1609,16 @@ void static ProcessGetBlockData(CNode* pfrom, const CChainParams& chainparams, c
16091609}
16101610
16111611// ! 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)
16131613{
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+
16141622 {
16151623 LOCK (cs_main);
16161624 // Look up transaction in relay pool
@@ -1661,7 +1669,7 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
16611669 continue ;
16621670 }
16631671
1664- CTransactionRef tx = FindTxForGetData (inv.hash , mempool_req, longlived_mempool_time);
1672+ CTransactionRef tx = FindTxForGetData (pfrom, inv.hash , mempool_req, longlived_mempool_time);
16651673 if (tx) {
16661674 int nSendFlags = (inv.type == MSG_TX ? SERIALIZE_TRANSACTION_NO_WITNESS : 0 );
16671675 connman->PushMessage (pfrom, msgMaker.Make (nSendFlags, NetMsgType::TX, *tx));
0 commit comments