Part of #19303.
This PR refactors per-peer transaction relay state so TxRelay owns its guarded data and lock boundaries before replacing its RecursiveMutex members with plain Mutex.
Before this change, Peer::TxRelay was mostly a collection of public state inside net_processing.cpp.
Callers directly locked its mutexes, inspected its fields, and mutated its containers.
That made the mutex type change hard to review: replacing RecursiveMutex with Mutex is only clearly safe if outside code cannot accidentally recurse, take locks in the wrong order, or bypass the intended state transitions.
The main changes are:
- Move
Peer::TxRelayintonode::TxRelay. - Route bloom-filter and transaction-inventory state changes through named
TxRelaymethods. - Remove direct
TxRelayfield and mutex access fromnet_processing.cpp. - Snapshot queued transaction inventory into a
TxInventoryBatchinSendMessages(), process it without holding theTxRelaymutex, and merge unsent entries back afterward. - Hide the batch backing storage behind a small semantic API.
- Add unit tests and a fuzz target for the extracted
TxRelaybehavior. - Replace the two
RecursiveMutexmembers withMutexand annotate the inventory-before-bloom lock order.
No P2P behavior change is intended. The purpose is to move from "external code locks and mutates TxRelay internals" to "TxRelay owns its state transitions and locking contract."
The most important commit to review is the SendMessages() batch snapshot refactor, because that is where the lock ownership model changes. The final mutex replacement is intentionally small after the state has been encapsulated.