diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 08815dc6b0e1e..c94ea82b7c57a 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -637,7 +637,7 @@ class PeerManagerImpl final : public PeerManager /** * Private implementation of IsInvInFilter which does not call GetPeerRef; to be prefered when the PeerRef is available. */ - bool IsInvInFilter(const PeerRef& peer, const uint256& hash) const EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex); + bool IsInvInFilter(const PeerRef& peer, const uint256& hash) const; /** Get a shared pointer to the Peer object. * May return an empty shared_ptr if the Peer object can't be found. */ @@ -2252,23 +2252,16 @@ void PeerManagerImpl::AskPeersForTransaction(const uint256& txid, bool is_master std::vector peersToAsk; peersToAsk.reserve(4); - auto maybe_add_to_nodesToAskFor = [&](const PeerRef& peer) { - if (peersToAsk.size() >= 4) { - return false; - } - if (IsInvInFilter(peer, txid)) { - peersToAsk.emplace_back(peer); - } - return true; - }; - { LOCK(m_peer_mutex); // TODO consider prioritizing MNs again, once that flag is moved into Peer for (const auto& [_, peer] : m_peer_map) { - if (!maybe_add_to_nodesToAskFor(peer)) { + if (peersToAsk.size() >= 4) { break; } + if (IsInvInFilter(peer, txid)) { + peersToAsk.emplace_back(peer); + } } } {