-
Notifications
You must be signed in to change notification settings - Fork 37.8k
refactor: replace CNode pointers by references within net_processing.{h,cpp} #19053
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
refactor: replace CNode pointers by references within net_processing.{h,cpp} #19053
Conversation
Concept ACK for the reasons you mention. Review should be easy, but this might conflict with some other work in net processing which is going on right now. Let's wait for DrahtBot to list the conflicts to get a better idea when a change like this is least disruptive. |
concept ACK(boo pointers) and agree this should be fairly simple to review. |
Very mild concept ACK. Pass-by-reference makes sense for |
a9b2cd9
to
cbd6094
Compare
Strong concept ACK |
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. |
Hm. Let's wait until a bunch of those conflicts are in first. |
This comment has been minimized.
This comment has been minimized.
@practicalswift This seems off-topic here. They need a case-by-case evaluation. I suggest you create a brainstorming issue to discuss this. |
@MarcoFalke Yes, that these need case-by-case evaluation goes without saying: the lists are showing potential candidates only -- sorry if that was unclear :) |
Thanks to all for the quick conceptual reviews! Will rebase every once in a while to get an updated list of conflicts by Drahtbot. @practicalswift: Nice, that's for sure helpful commands for finding more replace-pointers-by-references candidates (always impressed by your mega-grep-sed-etc..-chains ;-)). I agree with MarcoFalke though that opening an issue would make sense here, also to potentially attract more people discussing/working on this. |
c964281
to
a570157
Compare
Rebased. |
has three acks already, so let's get that in before this one. |
Review comment from #19044 (#19044 (comment)): since the parameters are no longer pointers, they shouldn't be called |
Doesn't |
Will review after rebase |
a570157
to
8b3136b
Compare
Rebased.
Thanks, good point! Before I start renaming: are there any other opinions on the naming suggestions? I also think |
ACK 8b3136b 🔻 Show signature and timestampSignature:
Timestamp of file with hash |
I like that the only changes are So my preference would be to keep the names as they were, but no strong opinion. Though, if the names are changed, it should be done in a new commit, so that scripts can be used to help review. |
ACK 8b3136b Checked that set of inserted/deleted characters appear to be limited to
|
…ithin net_processing.{h,cpp} 8b3136b refactor: replace CNode pointers by references within net_processing.{h,cpp} (Sebastian Falbesoner) Pull request description: This PR is inspired by a [recent code review comment](bitcoin#19010 (comment)) on a PR that introduced new functions to the net_processing module. The point of the discussion was basically that whenever we pass something not by value (in the concrete example it was about `CNode*` and `CConnman*`) we should either use * a pointer (```CType*```) with null pointer check or * a reference (```CType&```) To keep things simple, this PR for a first approach * only tackles `CNode*` pointers * only within the net_processing module, i.e. no changes that would need adaption in other modules * keeps the names of the variables as they are I'm aware that PRs like this are kind of a PITA to review, but I think the code quality would increase if we get rid of pointers without nullptr check -- bloating up the code by adding all the missing checks would be the worse alternative, in my opinion. Possible follow-up PRs, in case this is received well: * replace CNode pointers by references for net module * replace CConnman pointers by references for net_processing module * ... ACKs for top commit: MarcoFalke: ACK 8b3136b 🔻 practicalswift: ACK 8b3136b Tree-SHA512: 15b6a569ecdcb39341002b9f4e09b38ed4df077e3a3a50dfb1b72d98bdc9f9769c7c504f106456aa7748af8591af7bb836b72d46086df715ab116e4ac3224b3b
…tx_verify.{h,cpp} b00266f refactor: replace pointers by references within tx_verify.{h,cpp} (Sebastian Falbesoner) Pull request description: This PR gets rid of another unnecessary use of raw pointers, similar to PR bitcoin#19053 (see also issue bitcoin#19062 where useful commands for finding potential candidates are listed) but in the tx verification module. For the functions `CalculateSequenceLocks()` and `SequenceLocks()`, the `prevHeights` vector parameter type is changed to be passed as a reference. Note that there were no checks for null pointers -- if one would pass `nullptr` to one of the functions, the following line would immediately lead to a crash: https://github.com/bitcoin/bitcoin/blob/dcacea096e029a02a937bf96d002ca7e94c48c15/src/consensus/tx_verify.cpp#L32 ACKs for top commit: Empact: Code Review ACK bitcoin@b00266f Tree-SHA512: 0eb71591467905434082029128bdca4df94988c372af40dca325654f6c002c72a00c73776cb5e72d6de2b2f218649211a5dbf19300a2e01f1841d6034e0f01e0
…tx_verify.{h,cpp} b00266f refactor: replace pointers by references within tx_verify.{h,cpp} (Sebastian Falbesoner) Pull request description: This PR gets rid of another unnecessary use of raw pointers, similar to PR bitcoin#19053 (see also issue bitcoin#19062 where useful commands for finding potential candidates are listed) but in the tx verification module. For the functions `CalculateSequenceLocks()` and `SequenceLocks()`, the `prevHeights` vector parameter type is changed to be passed as a reference. Note that there were no checks for null pointers -- if one would pass `nullptr` to one of the functions, the following line would immediately lead to a crash: https://github.com/bitcoin/bitcoin/blob/dcacea096e029a02a937bf96d002ca7e94c48c15/src/consensus/tx_verify.cpp#L32 ACKs for top commit: Empact: Code Review ACK bitcoin@b00266f Tree-SHA512: 0eb71591467905434082029128bdca4df94988c372af40dca325654f6c002c72a00c73776cb5e72d6de2b2f218649211a5dbf19300a2e01f1841d6034e0f01e0
…t_processing.cpp 0c8461a refactor: replace CConnman pointers by references in net_processing.cpp (Sebastian Falbesoner) Pull request description: This is a follow-up to the recently merged PR bitcoin/bitcoin#19053, replacing ~~two more types of~~ one more type of pointer (CConnman) by references to increase the code quality -- pointers should either check for `nullptr` or be replaced by references, and the latter strategy seems to be more reasonable. Again, to keep the review burden managable, the changes are kept simple, * only tackling `CConnman*` ~~and `BanMan*`~~ pointers * only within the net_processing module, i.e. no changes that would need adaption in other modules * keeping the names of the variables as they are ACKs for top commit: jnewbery: utACK 0c8461a MarcoFalke: ACK 0c8461a 🕧 Tree-SHA512: 79dc05144bcfb5e0bbc62180285aadcc6199f044fa3016c0f54f7b7f45037415260970037bd63b18fafefb8aef448549dae14b780bafb540fa2373f493a17f71
…s in net_processing.cpp 0c8461a refactor: replace CConnman pointers by references in net_processing.cpp (Sebastian Falbesoner) Pull request description: This is a follow-up to the recently merged PR bitcoin#19053, replacing ~~two more types of~~ one more type of pointer (CConnman) by references to increase the code quality -- pointers should either check for `nullptr` or be replaced by references, and the latter strategy seems to be more reasonable. Again, to keep the review burden managable, the changes are kept simple, * only tackling `CConnman*` ~~and `BanMan*`~~ pointers * only within the net_processing module, i.e. no changes that would need adaption in other modules * keeping the names of the variables as they are ACKs for top commit: jnewbery: utACK 0c8461a MarcoFalke: ACK 0c8461a 🕧 Tree-SHA512: 79dc05144bcfb5e0bbc62180285aadcc6199f044fa3016c0f54f7b7f45037415260970037bd63b18fafefb8aef448549dae14b780bafb540fa2373f493a17f71
…{h,cpp} Summary: ``` This PR is inspired by a recent code review comment on a PR that introduced new functions to the net_processing module. The point of the discussion was basically that whenever we pass something not by value (in the concrete example it was about CNode* and CConnman*) we should either use a pointer (CType*) with null pointer check or a reference (CType&) To keep things simple, this PR for a first approach only tackles CNode* pointers only within the net_processing module, i.e. no changes that would need adaption in other modules keeps the names of the variables as they are I'm aware that PRs like this are kind of a PITA to review, but I think the code quality would increase if we get rid of pointers without nullptr check -- bloating up the code by adding all the missing checks would be the worse alternative, in my opinion. Possible follow-up PRs, in case this is received well: replace CNode pointers by references for net module replace CConnman pointers by references for net_processing module ... ``` Backport of core [[bitcoin/bitcoin#19053 | PR19053]]. Depends on D8469. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Subscribers: jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D8470
This PR is inspired by a recent code review comment on a PR that introduced new functions to the net_processing module. The point of the discussion was basically that whenever we pass something not by value (in the concrete example it was about
CNode*
andCConnman*
) we should either useCType*
) with null pointer check orCType&
)To keep things simple, this PR for a first approach
CNode*
pointersI'm aware that PRs like this are kind of a PITA to review, but I think the code quality would increase if we get rid of pointers without nullptr check -- bloating up the code by adding all the missing checks would be the worse alternative, in my opinion.
Possible follow-up PRs, in case this is received well: