From 4581a682d2d1fdd0e56fb4a56e6228be878a04a3 Mon Sep 17 00:00:00 2001 From: 0xb10c Date: Wed, 3 May 2023 00:24:22 +0200 Subject: [PATCH] clarify processing of mempool-msgs when NODE_BLOOM Under which circumstances we process received 'mempool' P2P messages caused confusion in #27426. Rather than bikeshedding the formulation of the IF-statement, this adds a comment clarifing when we process the message. Also, correcting the comment of `m_send_mempool`. Co-authored-by: willcl-ark --- src/net_processing.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index c50aa2e4f9b12..f5552cfcd8a5e 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -292,7 +292,8 @@ struct Peer { * this does not have to be sorted. */ std::set m_tx_inventory_to_send GUARDED_BY(m_tx_inventory_mutex); /** Whether the peer has requested us to send our complete mempool. Only - * permitted if the peer has NetPermissionFlags::Mempool. See BIP35. */ + * permitted if the peer has NetPermissionFlags::Mempool or we advertise + * NODE_BLOOM. See BIP35. */ bool m_send_mempool GUARDED_BY(m_tx_inventory_mutex){false}; /** The last time a BIP35 `mempool` request was serviced. */ std::atomic m_last_mempool_req{0s}; @@ -4600,6 +4601,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, } if (msg_type == NetMsgType::MEMPOOL) { + // Only process received mempool messages if we advertise NODE_BLOOM + // or if the peer has mempool permissions. if (!(peer->m_our_services & NODE_BLOOM) && !pfrom.HasPermission(NetPermissionFlags::Mempool)) { if (!pfrom.HasPermission(NetPermissionFlags::NoBan))