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

da0b8e2ce1 refactor: drop unneeded MIN_PEER_PROTO_VERSION from RelayInv (pasta)
94da0de6ef refactor: implement minimal RelayInv which doesn't rely on m_connman (pasta)

Pull request description:

  ## Issue being fixed or feature implemented
  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

  ## What was done?
  new implementation of RelayInv which doesn't rely on m_connman

  ## How Has This Been Tested?
  See CI

  ## Breaking Changes

  ## Checklist:
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  kwvg:
    utACK da0b8e2ce1
  knst:
    utACK da0b8e2ce1
  UdjinM6:
    utACK da0b8e2ce1

Tree-SHA512: 55e3e18607f3da104a943e09b29068ecf3bced869efbc804d6242c818ec3f7eb6768ea0cc6a409677559d3206dfc21bfff096a050ebbeb903e3fc2883e9bc8a4
This commit is contained in:
pasta 2024-12-02 13:31:43 -06:00
commit eba9ef06e8
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38
2 changed files with 13 additions and 2 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()};
@ -3429,7 +3439,7 @@ void PeerManagerImpl::PostProcessMessage(MessageProcessingResult&& result, NodeI
WITH_LOCK(cs_main, RelayTransaction(tx)); WITH_LOCK(cs_main, RelayTransaction(tx));
} }
if (result.m_inventory) { if (result.m_inventory) {
RelayInv(result.m_inventory.value(), MIN_PEER_PROTO_VERSION); RelayInv(result.m_inventory.value());
} }
} }

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;