@@ -317,10 +317,6 @@ struct Peer {
317
317
{
318
318
return WITH_LOCK (m_tx_relay_mutex, return m_tx_relay.get ());
319
319
};
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
- };
324
320
325
321
/* * A vector of addresses to send to the peer, limited to MAX_ADDR_TO_SEND. */
326
322
std::vector<CAddress> m_addrs_to_send GUARDED_BY (NetEventsInterface::g_msgproc_mutex);
@@ -908,8 +904,8 @@ class PeerManagerImpl final : public PeerManager
908
904
std::atomic<std::chrono::seconds> m_last_tip_update{0s};
909
905
910
906
/* * 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)
912
- LOCKS_EXCLUDED(cs_main) EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex);
907
+ CTransactionRef FindTxForGetData (const Peer::TxRelay& tx_relay , const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now)
908
+ EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex);
913
909
914
910
void ProcessGetData (CNode& pfrom, Peer& peer, const std::atomic<bool >& interruptMsgProc)
915
911
EXCLUSIVE_LOCKS_REQUIRED(!m_most_recent_block_mutex, peer.m_getdata_requests_mutex, NetEventsInterface::g_msgproc_mutex)
@@ -920,9 +916,9 @@ class PeerManagerImpl final : public PeerManager
920
916
921
917
/* * Relay map (txid or wtxid -> CTransactionRef) */
922
918
typedef std::map<uint256, CTransactionRef> MapRelay;
923
- MapRelay mapRelay GUARDED_BY (cs_main );
919
+ MapRelay mapRelay GUARDED_BY (NetEventsInterface::g_msgproc_mutex );
924
920
/* * Expiration-time ordered list of (expire time, relay map entry) pairs. */
925
- std::deque<std::pair<std::chrono::microseconds, MapRelay::iterator>> g_relay_expiration GUARDED_BY (cs_main );
921
+ std::deque<std::pair<std::chrono::microseconds, MapRelay::iterator>> g_relay_expiration GUARDED_BY (NetEventsInterface::g_msgproc_mutex );
926
922
927
923
/* *
928
924
* When a peer sends us a valid block, instruct it to announce blocks to us
@@ -2258,7 +2254,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
2258
2254
}
2259
2255
}
2260
2256
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)
2262
2258
{
2263
2259
auto txinfo = m_mempool.info (gtxid);
2264
2260
if (txinfo.tx ) {
@@ -2270,16 +2266,13 @@ CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer& peer, const GenTxi
2270
2266
}
2271
2267
}
2272
2268
2273
- {
2274
- LOCK (cs_main);
2275
- // Otherwise, the transaction must have been announced recently.
2276
- if (Assume (peer.GetTxRelay ())->m_recently_announced_invs .contains (gtxid.GetHash ())) {
2277
- // If it was, it can be relayed from either the mempool...
2278
- if (txinfo.tx ) return std::move (txinfo.tx );
2279
- // ... or the relay pool.
2280
- auto mi = mapRelay.find (gtxid.GetHash ());
2281
- if (mi != mapRelay.end ()) return mi->second ;
2282
- }
2269
+ // Otherwise, the transaction must have been announced recently.
2270
+ if (tx_relay.m_recently_announced_invs .contains (gtxid.GetHash ())) {
2271
+ // If it was, it can be relayed from either the mempool...
2272
+ if (txinfo.tx ) return std::move (txinfo.tx );
2273
+ // ... or the relay pool.
2274
+ auto mi = mapRelay.find (gtxid.GetHash ());
2275
+ if (mi != mapRelay.end ()) return mi->second ;
2283
2276
}
2284
2277
2285
2278
return {};
@@ -2316,7 +2309,7 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
2316
2309
continue ;
2317
2310
}
2318
2311
2319
- CTransactionRef tx = FindTxForGetData (peer , ToGenTxid (inv), mempool_req, now);
2312
+ CTransactionRef tx = FindTxForGetData (*tx_relay , ToGenTxid (inv), mempool_req, now);
2320
2313
if (tx) {
2321
2314
// WTX and WITNESS_TX imply we serialize with witness
2322
2315
int nSendFlags = (inv.IsMsgTx () ? SERIALIZE_TRANSACTION_NO_WITNESS : 0 );
0 commit comments