-
Notifications
You must be signed in to change notification settings - Fork 38.7k
refactor: Move stuff to ChainstateManager #23785
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
The helper was moved in commit b026e31, which also mentioned that it could be moved to CChainState. So do that, as the functionality is not block-storage related. This also allows to drop one function argument.
This is needed for the next commit.
The member is unrelated to block storage (BlockManager). It is related to validation. Fix the confusion by moving it. Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
A private member is better than a global.
|
This is required for and split off of #23581 |
| * ahead and mark descendants of invalid blocks as FAILED_CHILD at that time, | ||
| * instead of putting things in this set. | ||
| */ | ||
| std::set<CBlockIndex*> m_failed_blocks; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably irrelevant, but would it make sense to make it unordered_set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe as a separate pull? I want to keep this move-only refactoring and not change the behaviour/performance.
|
ACK fab6d6b |
1 similar comment
|
ACK fab6d6b |
shaavan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fab6d6b
The refactoring looks clean, and it was easy to rationalize each change since you provided reasoning in the commit message itself. Thanks for that!
| //! by the background validation chainstate. | ||
| bool m_snapshot_validated{false}; | ||
|
|
||
| CBlockIndex* m_best_invalid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just curious, though. How about naming this variable to:
| CBlockIndex* m_best_invalid; | |
| CBlockIndex* m_best_invalid_index; |
or to:
| CBlockIndex* m_best_invalid; | |
| CBlockIndex* m_index_best_invalid; |
Because:
- This would help express the purpose of this variable more clearly.
- Since this replaces
pindexBestInvalid, it makes it more logical to name it this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively m_best_invalid_block_index, though that's a bit long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I am not a fan of putting the type of the symbol in the name of the symbol.
For example, I think we prefer std::string name over std::string strName or std::string name_string.
Also, leaving as-is for now to not invalidate reviews.
Summary: > The helper was moved in commit b026e318c39f59a06e29f1b25c7f577e01b25ccb, > which also mentioned that it could be moved to CChainState. So do that, > as the functionality is not block-storage related. > > This also allows to drop one function argument. This is a backport of [[bitcoin/bitcoin#23785 | core#23785]] bitcoin/bitcoin@fa3d62c Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D12484
Summary: This is needed for the next commit. Note that `m_chainman` was made `const` by us in D12227 when backporting "validation: add chainman ref to CChainState" ([[bitcoin/bitcoin#21526 | core#21526]]), because we could. In this commit is need to be made non-const so `m_chainman.AcceptBlockHeader` can be called. This member function cannot be made const. This is a backport of [[bitcoin/bitcoin#23785 | core#23785]] bitcoin/bitcoin@fa47b5c Depends on D12484 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D12485
Summary: The member is unrelated to block storage (BlockManager). It is related to validation. Fix the confusion by moving it. Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space This is a partial backport of [[bitcoin/bitcoin#23785 | core#23785]] bitcoin/bitcoin@facd213 Depends on D12485 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D12486
Summary: A private member is better than a global. This concludes backport of [[bitcoin/bitcoin#23785 | core#23785]] bitcoin/bitcoin@fab6d6b Depends on D12486 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D12487
Move globals or members of the wrong class to the right class.