Skip to content

Commit

Permalink
clarify processing of mempool-msgs when NODE_BLOOM
Browse files Browse the repository at this point in the history
Under which circumstances we process received 'mempool' P2P messages
caused confusion in bitcoin#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 <will8clark@gmail.com>
  • Loading branch information
2 people authored and RandyMcMillan committed May 27, 2023
1 parent 3fd7473 commit fb0a4c4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ struct Peer {
* this does not have to be sorted. */
std::set<uint256> 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<std::chrono::seconds> m_last_mempool_req{0s};
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit fb0a4c4

Please sign in to comment.