This PR is a continuation of →https://github.com/bitcoin/bitcoin/pull/22850, to make m_mempool an optional pointer in PeerManager instead of a reference.
some benefits, as mentioned here:https://github.com/bitcoin/bitcoin/pull/26247#issue-1396302764 are:
- m_mempool is already a pointer in other parts like: In Chainstate: https://github.com/bitcoin/bitcoin/blob/master/src/validation.h#L532 In BlockAssembler: https://github.com/bitcoin/bitcoin/blob/master/src/node/miner.h#L168 So adding this to PeerManager improves consistency.
- Having m_mempool as a pointer also makes it easier to test scenarios where the mempool is not required.
- I’m not sure if
-nomempool
is still being considered, but if it is, then this pointer approach would be a necessary prerequisite.
There was a suggestion here -> #26247 (comment) to refactor/introduce helper functions like RejectIncomingTxs
that would return m_mempoo
l, but I’m not entirely sure about this approach.this wouldn’t be ideal since in some call sites like PushNodeVersion
and NetMsgType::SENDTXRCNCL
, mempool isn’t needed at all.
I’d like to continue working on this, and I’m looking for feedback on whether this is still relevant and which approach to go with. Should I follow the suggestion to add helper functions that return the m_mempool pointer, or should I stick with checking if m_mempool is null, or perhaps consider a different approach altogether?