Skip to content

Commit 3fa4c54

Browse files
committed
[net processing] Pass TxRelay to FindTxForGetData instead of Peer
1 parent c85ee76 commit 3fa4c54

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,6 @@ struct Peer {
317317
{
318318
return WITH_LOCK(m_tx_relay_mutex, return m_tx_relay.get());
319319
};
320-
const TxRelay* GetTxRelay() const EXCLUSIVE_LOCKS_REQUIRED(!m_tx_relay_mutex)
321-
{
322-
return WITH_LOCK(m_tx_relay_mutex, return m_tx_relay.get());
323-
};
324320

325321
/** A vector of addresses to send to the peer, limited to MAX_ADDR_TO_SEND. */
326322
std::vector<CAddress> m_addrs_to_send GUARDED_BY(NetEventsInterface::g_msgproc_mutex);
@@ -908,7 +904,7 @@ class PeerManagerImpl final : public PeerManager
908904
std::atomic<std::chrono::seconds> m_last_tip_update{0s};
909905

910906
/** Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed). */
911-
CTransactionRef FindTxForGetData(const Peer& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now)
907+
CTransactionRef FindTxForGetData(const Peer::TxRelay& tx_relay, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now)
912908
EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex);
913909

914910
void ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc)
@@ -2258,7 +2254,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
22582254
}
22592255
}
22602256

2261-
CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now)
2257+
CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer::TxRelay& tx_relay, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now)
22622258
{
22632259
auto txinfo = m_mempool.info(gtxid);
22642260
if (txinfo.tx) {
@@ -2271,7 +2267,7 @@ CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer& peer, const GenTxi
22712267
}
22722268

22732269
// Otherwise, the transaction must have been announced recently.
2274-
if (Assume(peer.GetTxRelay())->m_recently_announced_invs.contains(gtxid.GetHash())) {
2270+
if (tx_relay.m_recently_announced_invs.contains(gtxid.GetHash())) {
22752271
// If it was, it can be relayed from either the mempool...
22762272
if (txinfo.tx) return std::move(txinfo.tx);
22772273
// ... or the relay pool.
@@ -2313,7 +2309,7 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
23132309
continue;
23142310
}
23152311

2316-
CTransactionRef tx = FindTxForGetData(peer, ToGenTxid(inv), mempool_req, now);
2312+
CTransactionRef tx = FindTxForGetData(*tx_relay, ToGenTxid(inv), mempool_req, now);
23172313
if (tx) {
23182314
// WTX and WITNESS_TX imply we serialize with witness
23192315
int nSendFlags = (inv.IsMsgTx() ? SERIALIZE_TRANSACTION_NO_WITNESS : 0);

0 commit comments

Comments
 (0)