Skip to content

Commit 88121b0

Browse files
Merge #6910: perf: bail out in RelayInvFiltered early if !CanRelay
a425211 perf: bail out in RelayInvFiltered early if !CanRelay (pasta) Pull request description: ## Issue being fixed or feature implemented m_peer_mutex, acquired in GetPeerRef, is relatively highly contended. Move the pnode->CanRelay up higher to bail out early if possible and avoid the need to acquire m_peer_mutex. ## What was done? ## How Has This Been Tested? Builds ## Breaking Changes ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] 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: UdjinM6: utACK a425211 Tree-SHA512: bdeb868ace02c0ef27a8048fa3172847d88cf51392c8d8180b4ea08465a12f3f5248917fbdcd4be6c8ab8f6ad10c05b2a2c9af42ab1586a58a6142ab7788d0f5
2 parents e5ce1f0 + a425211 commit 88121b0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2406,11 +2406,13 @@ void PeerManagerImpl::RelayInvFiltered(const CInv& inv, const CTransaction& rela
24062406
{
24072407
// TODO: Migrate to iteration through m_peer_map
24082408
m_connman.ForEachNode([&](CNode* pnode) {
2409+
if (!pnode->CanRelay()) return;
2410+
24092411
PeerRef peer = GetPeerRef(pnode->GetId());
24102412
if (peer == nullptr) return;
24112413

24122414
auto tx_relay = peer->GetTxRelay();
2413-
if (!pnode->CanRelay() || tx_relay == nullptr) {
2415+
if (tx_relay == nullptr) {
24142416
return;
24152417
}
24162418

0 commit comments

Comments
 (0)