Skip to content

Commit 290a8da

Browse files
committed
[net processing] Comment all TxRelay members
This fully comments all the TxRelay members. The only significant change is to the comment for m_relay_txs. Previously the comment stated that one of the purposes of the field was that "We don't relay tx invs before receiving the peer's version message". However, even without the m_relay_txs flag, we would not send transactions to the peer before receiving the `version` message, since SendMessages() returns immediately if fSuccessfullyConnected is not set to true, which only happens once a `version` and `verack` message have been received.
1 parent 42e3250 commit 290a8da

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/net_processing.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,25 +247,36 @@ struct Peer {
247247

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

257260
mutable RecursiveMutex m_tx_inventory_mutex;
261+
/** A filter of all the txids and wtxids that the peer has announced to
262+
* us or we have announced to the peer. We use this to avoid announcing
263+
* the same txid/wtxid to a peer that already has the transaction. */
258264
CRollingBloomFilter m_tx_inventory_known_filter GUARDED_BY(m_tx_inventory_mutex){50000, 0.000001};
259-
// Set of transaction ids we still have to announce.
260-
// They are sorted by the mempool before relay, so the order is not important.
265+
/** Set of transaction ids we still have to announce (txid for
266+
* non-wtxid-relay peers, wtxid for wtxid-relay peers). We use the
267+
* mempool to sort transactions in dependency order before relay, so
268+
* this does not have to be sorted. */
261269
std::set<uint256> m_tx_inventory_to_send;
262-
// Used for BIP35 mempool sending
270+
/** Whether the peer has requested us to send our complete mempool. Only
271+
* permitted if the peer has NetPermissionFlags::Mempool. See BIP35. */
263272
bool m_send_mempool GUARDED_BY(m_tx_inventory_mutex){false};
264-
// Last time a "MEMPOOL" request was serviced.
273+
/** The last time a BIP35 `mempool` request was serviced. */
265274
std::atomic<std::chrono::seconds> m_last_mempool_req{0s};
275+
/** The next time after which we will send an `inv` message containing
276+
* transaction announcements to this peer. */
266277
std::chrono::microseconds m_next_inv_send_time{0};
267278

268-
/** Minimum fee rate with which to filter inv's to this node */
279+
/** Minimum fee rate with which to filter transaction announcements to this node. See BIP133. */
269280
std::atomic<CAmount> m_fee_filter_received{0};
270281
};
271282

0 commit comments

Comments
 (0)