Skip to content

Commit a9819b0

Browse files
committed
refactor: Change FindTxForGetData to take GenTxid instead of CInv
Addresses bitcoin/bitcoin#32631 (comment) from #32631
1 parent d588575 commit a9819b0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ class PeerManagerImpl final : public PeerManager
947947
std::atomic<std::chrono::seconds> m_last_tip_update{0s};
948948

949949
/** Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed). */
950-
CTransactionRef FindTxForGetData(const Peer::TxRelay& tx_relay, const CInv& inv)
950+
CTransactionRef FindTxForGetData(const Peer::TxRelay& tx_relay, const GenTxid& gtxid)
951951
EXCLUSIVE_LOCKS_REQUIRED(!m_most_recent_block_mutex, NetEventsInterface::g_msgproc_mutex);
952952

953953
void ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc)
@@ -2391,15 +2391,14 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
23912391
}
23922392
}
23932393

2394-
CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer::TxRelay& tx_relay, const CInv& inv)
2394+
CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer::TxRelay& tx_relay, const GenTxid& gtxid)
23952395
{
2396-
auto gtxid{ToGenTxid(inv)};
2397-
// If a tx was in the mempool prior to the last INV for this peer, permit the request.
23982396
auto txinfo{std::visit(
23992397
[&](const auto& id) EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex) {
24002398
return m_mempool.info_for_relay(id, tx_relay.m_last_inv_sequence);
24012399
},
24022400
gtxid)};
2401+
24032402
if (txinfo.tx) {
24042403
return std::move(txinfo.tx);
24052404
}
@@ -2442,7 +2441,7 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
24422441
continue;
24432442
}
24442443

2445-
if (auto tx{FindTxForGetData(*tx_relay, inv)}) {
2444+
if (auto tx{FindTxForGetData(*tx_relay, ToGenTxid(inv))}) {
24462445
// WTX and WITNESS_TX imply we serialize with witness
24472446
const auto maybe_with_witness = (inv.IsMsgTx() ? TX_NO_WITNESS : TX_WITH_WITNESS);
24482447
MakeAndPushMessage(pfrom, NetMsgType::TX, maybe_with_witness(*tx));

0 commit comments

Comments
 (0)