Skip to content

Commit 53eb4b7

Browse files
committed
Merge bitcoin/bitcoin#27270: refactor, net processing: Avoid CNode::m_relays_txs usage
55c4795 [net processing] Use TxRelay::m_relay_txs over CNode::m_relays_txs (dergoegge) Pull request description: `CNode::m_relays_txs` is meant to only be used for the eviction logic in `net`. `TxRelay::m_relay_txs` will hold the same value and is meant to be used on the application layer to determine if we will/should relay transactions to a peer. (Shameless plug: we should really better specify the interface for updating eviction data to avoid refactors like this in the future -> #25572) ACKs for top commit: MarcoFalke: lgtm ACK 55c4795 Tree-SHA512: 59cfd23e32568fd96cda5570790e518242a6c76d4edf5b7d1a2a7f9724d590d2a38395504e05be0af4e98dd5c0056fc0be6568eab2818934692483a186e5181d
2 parents b24553c + 55c4795 commit 53eb4b7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/net_processing.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3296,11 +3296,13 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
32963296
if (greatest_common_version >= WTXID_RELAY_VERSION && m_txreconciliation) {
32973297
// Per BIP-330, we announce txreconciliation support if:
32983298
// - protocol version per the peer's VERSION message supports WTXID_RELAY;
3299-
// - transaction relay is supported per the peer's VERSION message (see m_relays_txs);
3300-
// - this is not a block-relay-only connection and not a feeler (see m_relays_txs);
3299+
// - transaction relay is supported per the peer's VERSION message
3300+
// - this is not a block-relay-only connection and not a feeler
33013301
// - this is not an addr fetch connection;
33023302
// - we are not in -blocksonly mode.
3303-
if (pfrom.m_relays_txs && !pfrom.IsAddrFetchConn() && !m_ignore_incoming_txs) {
3303+
const auto* tx_relay = peer->GetTxRelay();
3304+
if (tx_relay && WITH_LOCK(tx_relay->m_bloom_filter_mutex, return tx_relay->m_relay_txs) &&
3305+
!pfrom.IsAddrFetchConn() && !m_ignore_incoming_txs) {
33043306
const uint64_t recon_salt = m_txreconciliation->PreRegisterPeer(pfrom.GetId());
33053307
m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::SENDTXRCNCL,
33063308
TXRECONCILIATION_VERSION, recon_salt));
@@ -3528,7 +3530,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
35283530
// Peer must not offer us reconciliations if they specified no tx relay support in VERSION.
35293531
// This flag might also be false in other cases, but the RejectIncomingTxs check above
35303532
// eliminates them, so that this flag fully represents what we are looking for.
3531-
if (!pfrom.m_relays_txs) {
3533+
const auto* tx_relay = peer->GetTxRelay();
3534+
if (!tx_relay || !WITH_LOCK(tx_relay->m_bloom_filter_mutex, return tx_relay->m_relay_txs)) {
35323535
LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "sendtxrcncl received from peer=%d which indicated no tx relay to us; disconnecting\n", pfrom.GetId());
35333536
pfrom.fDisconnect = true;
35343537
return;

0 commit comments

Comments
 (0)