Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Dec 15, 2021

Move globals or members of the wrong class to the right class.

MarcoFalke added 4 commits December 15, 2021 17:45
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.
@maflcko
Copy link
Member Author

maflcko commented Dec 15, 2021

This is required for and split off of #23581

@maflcko maflcko changed the title 2112 move c man refactor: Move stuff to ChainstateManager Dec 15, 2021
* 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;
Copy link
Contributor

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?

Copy link
Member Author

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.

@naumenkogs
Copy link
Contributor

ACK fab6d6b

1 similar comment
@Sjors
Copy link
Member

Sjors commented Dec 16, 2021

ACK fab6d6b

Copy link
Contributor

@shaavan shaavan left a 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;
Copy link
Contributor

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:

Suggested change
CBlockIndex* m_best_invalid;
CBlockIndex* m_best_invalid_index;

or to:

Suggested change
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.

Copy link
Member

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

Copy link
Member Author

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.

@maflcko maflcko merged commit 8c0bd87 into bitcoin:master Dec 16, 2021
@maflcko maflcko deleted the 2112-moveCMan branch December 16, 2021 14:19
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 16, 2021
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 16, 2022
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
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 16, 2022
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
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 16, 2022
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
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 16, 2022
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
@bitcoin bitcoin locked and limited conversation to collaborators Dec 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants