refactor: implement minimal RelayInv which doesn't rely on m_connman

Vast majority of usages of RelayInv don't use the minProtoVersion, we may as well have these not contribute to contention of m_nodes_mutex / use m_connman
This commit is contained in:
pasta 2024-11-23 00:28:13 -06:00
parent c2b83dc80e
commit 94da0de6ef
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38
2 changed files with 12 additions and 1 deletions

View File

@ -614,6 +614,7 @@ public:
bool IgnoresIncomingTxs() override { return m_ignore_incoming_txs; } bool IgnoresIncomingTxs() override { return m_ignore_incoming_txs; }
void SendPings() override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);; void SendPings() override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);;
void PushInventory(NodeId nodeid, const CInv& inv) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex); void PushInventory(NodeId nodeid, const CInv& inv) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void RelayInv(CInv &inv) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void RelayInv(CInv &inv, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex); void RelayInv(CInv &inv, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex); void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
void RelayInvFiltered(CInv &inv, const uint256 &relatedTxHash, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex); void RelayInvFiltered(CInv &inv, const uint256 &relatedTxHash, const int minProtoVersion) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
@ -2289,6 +2290,15 @@ void PeerManagerImpl::RelayInv(CInv &inv, const int minProtoVersion)
}); });
} }
void PeerManagerImpl::RelayInv(CInv &inv)
{
LOCK(m_peer_mutex);
for (const auto& [_, peer] : m_peer_map) {
if (!peer->GetInvRelay()) continue;
PushInv(*peer, inv);
}
}
void PeerManagerImpl::RelayDSQ(const CCoinJoinQueue& queue) void PeerManagerImpl::RelayDSQ(const CCoinJoinQueue& queue)
{ {
CInv inv{MSG_DSQ, queue.GetHash()}; CInv inv{MSG_DSQ, queue.GetHash()};

View File

@ -98,7 +98,8 @@ public:
virtual void RelayDSQ(const CCoinJoinQueue& queue) = 0; virtual void RelayDSQ(const CCoinJoinQueue& queue) = 0;
/** Relay inventories to all peers */ /** Relay inventories to all peers */
virtual void RelayInv(CInv &inv, const int minProtoVersion = MIN_PEER_PROTO_VERSION) = 0; virtual void RelayInv(CInv &inv) = 0;
virtual void RelayInv(CInv &inv, const int minProtoVersion) = 0;
virtual void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx, virtual void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx,
const int minProtoVersion = MIN_PEER_PROTO_VERSION) = 0; const int minProtoVersion = MIN_PEER_PROTO_VERSION) = 0;