Page MenuHomePhabricator

[net processing] Don't initialize TxRelay for non-tx-relay peers.
ClosedPublic

Authored by PiRK on Nov 6 2023, 08:41.

Details

Summary

[net processing] Add m_tx_relay_mutex to protect m_tx_relay ptr

[net processing] Don't initialize TxRelay for non-tx-relay peers.

Delay initializing the TxRelay data structure for a peer until we receive
a version message from that peer. At that point we'll know whether it
will ever relay transactions. We only initialize the m_tx_relay
data structure if:

  • this isn't an outbound block-relay-only connection; AND
  • fRelay=true OR we're offering NODE_BLOOM to this peer (NODE_BLOOM means that the peer may turn on tx relay later)

This concludes backport of core#22778
https://github.com/bitcoin/bitcoin/pull/22778/commits/b0a4ac9c26f60fd4993d89f45cafffaa389db2d4
https://github.com/bitcoin/bitcoin/pull/22778/commits/9db82f1bca0bb51c2180ca4a4ad63ba490e79da4

Depends on D14739

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Nov 6 2023, 08:41
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/net_processing.cpp
2063 ↗(On Diff #42955)

That should work the same (please double check)

2750 ↗(On Diff #42955)

dito

5921 ↗(On Diff #42955)

dito

This revision is now accepted and ready to land.Nov 6 2023, 12:08

declare tx_relay directly in the if's condition, skip the the init-statement