Skip to content

Commit 60b5392

Browse files
committed
partial bitcoin#22778: Reduce resource usage for inbound block-relay-only connections
includes: - 290a8da
1 parent 85c4aef commit 60b5392

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/net_processing.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,25 +272,34 @@ struct Peer {
272272

273273
struct TxRelay {
274274
mutable RecursiveMutex m_bloom_filter_mutex;
275-
// We use m_relay_txs for two purposes -
276-
// a) it allows us to not relay tx invs before receiving the peer's version message
277-
// b) the peer may tell us in its version message that we should not relay tx invs
278-
// unless it loads a bloom filter.
275+
/** Whether the peer wishes to receive transaction announcements.
276+
*
277+
* This is initially set based on the fRelay flag in the received
278+
* `version` message. If initially set to false, it can only be flipped
279+
* to true if we have offered the peer NODE_BLOOM services and it sends
280+
* us a `filterload` or `filterclear` message. See BIP37. */
279281
bool m_relay_txs GUARDED_BY(m_bloom_filter_mutex){false};
282+
/** A bloom filter for which transactions to announce to the peer. See BIP37. */
280283
std::unique_ptr<CBloomFilter> m_bloom_filter PT_GUARDED_BY(m_bloom_filter_mutex) GUARDED_BY(m_bloom_filter_mutex){nullptr};
281284

282285
mutable RecursiveMutex m_tx_inventory_mutex;
283-
// inventory based relay
286+
/** A filter of all the txids that the peer has announced to
287+
* us or we have announced to the peer. We use this to avoid announcing
288+
* the same txid to a peer that already has the transaction. */
284289
CRollingBloomFilter m_tx_inventory_known_filter GUARDED_BY(m_tx_inventory_mutex){50000, 0.000001};
285-
// Set of transaction ids we still have to announce.
286-
// They are sorted by the mempool before relay, so the order is not important.
290+
/** Set of transaction ids we still have to announce. We use the
291+
* mempool to sort transactions in dependency order before relay, so
292+
* this does not have to be sorted. */
287293
std::set<uint256> m_tx_inventory_to_send GUARDED_BY(m_tx_inventory_mutex);
288-
// List of non-tx/non-block inventory items
294+
/** List of non-tx/non-block inventory items */
289295
std::vector<CInv> vInventoryOtherToSend GUARDED_BY(m_tx_inventory_mutex);
290-
// Used for BIP35 mempool sending, also protected by m_tx_inventory_mutex
296+
/** Whether the peer has requested us to send our complete mempool. Only
297+
* permitted if the peer has NetPermissionFlags::Mempool. See BIP35. */
291298
bool m_send_mempool GUARDED_BY(m_tx_inventory_mutex){false};
292-
// Last time a "MEMPOOL" request was serviced.
299+
/** The last time a BIP35 `mempool` request was serviced. */
293300
std::atomic<std::chrono::seconds> m_last_mempool_req{0s};
301+
/** The next time after which we will send an `inv` message containing
302+
* transaction announcements to this peer. */
294303
std::chrono::microseconds m_next_inv_send_time GUARDED_BY(NetEventsInterface::g_msgproc_mutex){0};
295304
};
296305

0 commit comments

Comments
 (0)