Merge bitcoin/bitcoin#27559: doc: clarify processing of mempool-msgs when NODE_BLOOM

4581a682d2d1fdd0e56fb4a56e6228be878a04a3 clarify processing of mempool-msgs when NODE_BLOOM (0xb10c)

Pull request description:

  Under which circumstances we process received 'mempool' P2P messages caused confusion in #27426. Rather than bike-shedding the formulation of the IF-statement, this adds a comment clarifying when we process the message. Also, correcting the `m_send_mempool` description.

ACKs for top commit:
  dergoegge:
    ACK 4581a682d2d1fdd0e56fb4a56e6228be878a04a3
  willcl-ark:
    ACK 4581a682d2
  glozow:
    ACK 4581a682d2d1fdd0e56fb4a56e6228be878a04a3

Tree-SHA512: 51ec673c3446b67c26f6c715430d0708b998b256260f5f5d0c034f271be8447d0bb8540dfd3879aa51904512fb26c9411766786c86287acff62d037a1df88855
This commit is contained in:
glozow 2023-05-03 07:56:21 -04:00 committed by pasta
parent a4e429cb5a
commit 898dcbdc4f
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38

View File

@ -294,7 +294,8 @@ struct Peer {
/** List of non-tx/non-block inventory items */ /** List of non-tx/non-block inventory items */
std::vector<CInv> vInventoryOtherToSend GUARDED_BY(m_tx_inventory_mutex); std::vector<CInv> vInventoryOtherToSend GUARDED_BY(m_tx_inventory_mutex);
/** Whether the peer has requested us to send our complete mempool. Only /** 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}; bool m_send_mempool GUARDED_BY(m_tx_inventory_mutex){false};
/** The last time a BIP35 `mempool` request was serviced. */ /** The last time a BIP35 `mempool` request was serviced. */
std::atomic<std::chrono::seconds> m_last_mempool_req{0s}; std::atomic<std::chrono::seconds> m_last_mempool_req{0s};
@ -4726,6 +4727,8 @@ void PeerManagerImpl::ProcessMessage(
} }
if (msg_type == NetMsgType::MEMPOOL) { 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 (!(peer->m_our_services & NODE_BLOOM) && !pfrom.HasPermission(NetPermissionFlags::Mempool))
{ {
if (!pfrom.HasPermission(NetPermissionFlags::NoBan)) if (!pfrom.HasPermission(NetPermissionFlags::NoBan))