-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Replace m_tx_relay/nullptr checks in net_processing.cpp #20676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Semantically, whether m_tx_relay is a nullptr can mean that either the connection is a block-relay-only connection, or that we're relaying transactions on this connection. While there's currently a 1-1 mapping between those ideas right now, separate the two concepts more clearly so that in the future it'll be easier to reason about changes, particularly if we add more connection types which do not relay transactions.
This kind of refactor was requested in #19858 (comment). While I think it's helpful for I opted for the latter approach, because right now (nearly) all those nullptr checks are done before dereferencing |
Code review ACK c80de78, this does not change behavior |
Concept ACK. This seems much clearer to me. |
utACK c80de78 |
This idea was discussed in the original blocks only PR, https://github.com/bitcoin/bitcoin/pull/15759/files#r310366329 -- the reasoning was the explicit I tend to think |
@ajtowns Thanks for the reminder of that discussion, I had forgotten about it! I guess my uneasiness about removing It occurs to me that the problem may be a bigger issue around the separation between
I would also be okay with that an approach that checks for nullptr explicitly and also does the |
Maybe that will change as @jnewbery's net/net_processing separation stuff (#19398) progresses? It proposes moving all of |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Code review ACK c80de78
That's the hope. Eventually there should be much less reaching across the net/net_processing divide. net_processing eventually will need to access almost nothing from CNode. It might make sense to also have a |
It occurs to me that moving I could also just add an assert that |
I think that this is an improvement, but also agree that the same lines will need to be changed again when the tx inventory data is moved into net_processing, so it might make sense to just leave this for now. The next PR in the net/net_processing split series is #19829 if you'd like to help with that work. |
@jnewbery Sounds good to me, will close. |
Semantically, whether m_tx_relay is a nullptr can mean that either the
connection is a block-relay-only connection, or that we're relaying
transactions on this connection. While there's currently a 1-1 mapping between
those ideas right now, separate the two concepts more clearly so that in the
future it'll be easier to reason about changes, particularly if we add more
connection types which do not relay transactions.