diff options
author | dergoegge <n.goeggi@gmail.com> | 2023-03-31 12:53:46 +0200 |
---|---|---|
committer | dergoegge <n.goeggi@gmail.com> | 2023-03-31 13:18:39 +0200 |
commit | c85ee76a3647a42d3a59c28444c5ca52e7db7c5e (patch) | |
tree | 8cb0b51bdcab98841a6d8ab72379816c6d4e3670 | |
parent | 6b9fedd2211851a70d2d82dea04420e9b87bfff9 (diff) | |
download | bitcoin-c85ee76a3647a42d3a59c28444c5ca52e7db7c5e.tar.xz |
[net processin] Don't take cs_main in FindTxForGetData
Taking cs_main is no longer necessary since we moved
`m_recently_announced_invs` to `Peer` and `mapRelay` is actually only
accessed from the message processing thread.
-rw-r--r-- | src/net_processing.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 2348f6c059..29d123e16b 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -909,7 +909,7 @@ private: /** Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed). */ CTransactionRef FindTxForGetData(const Peer& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) - LOCKS_EXCLUDED(cs_main) EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex); + EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex); void ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(!m_most_recent_block_mutex, peer.m_getdata_requests_mutex, NetEventsInterface::g_msgproc_mutex) @@ -920,9 +920,9 @@ private: /** Relay map (txid or wtxid -> CTransactionRef) */ typedef std::map<uint256, CTransactionRef> MapRelay; - MapRelay mapRelay GUARDED_BY(cs_main); + MapRelay mapRelay GUARDED_BY(NetEventsInterface::g_msgproc_mutex); /** Expiration-time ordered list of (expire time, relay map entry) pairs. */ - std::deque<std::pair<std::chrono::microseconds, MapRelay::iterator>> g_relay_expiration GUARDED_BY(cs_main); + std::deque<std::pair<std::chrono::microseconds, MapRelay::iterator>> g_relay_expiration GUARDED_BY(NetEventsInterface::g_msgproc_mutex); /** * When a peer sends us a valid block, instruct it to announce blocks to us @@ -2270,16 +2270,13 @@ CTransactionRef PeerManagerImpl::FindTxForGetData(const Peer& peer, const GenTxi } } - { - LOCK(cs_main); - // Otherwise, the transaction must have been announced recently. - if (Assume(peer.GetTxRelay())->m_recently_announced_invs.contains(gtxid.GetHash())) { - // If it was, it can be relayed from either the mempool... - if (txinfo.tx) return std::move(txinfo.tx); - // ... or the relay pool. - auto mi = mapRelay.find(gtxid.GetHash()); - if (mi != mapRelay.end()) return mi->second; - } + // Otherwise, the transaction must have been announced recently. + if (Assume(peer.GetTxRelay())->m_recently_announced_invs.contains(gtxid.GetHash())) { + // If it was, it can be relayed from either the mempool... + if (txinfo.tx) return std::move(txinfo.tx); + // ... or the relay pool. + auto mi = mapRelay.find(gtxid.GetHash()); + if (mi != mapRelay.end()) return mi->second; } return {}; |