HomePhabricator

[refactor] make the finalized BlockIndex* a private member of CChainState

Description

[refactor] make the finalized BlockIndex* a private member of CChainState

Summary:
Upcoming Core PR16443 adds g_chainstate to validation.cpp, this caused a bit of a havoc with initializaion order of pindexFinalized (also declared in validation.cpp) so I took this opportunity to encapsulate the finalizedBlockIndex pointer into CChainState

additionally:

  • moved an assertion that cs_main lock must be held down to where the actual pointer is accessed, to guarantee that all code paths trigger that.
  • added an assert to prevent users from changing the finalizationBlockIndex pointer to nullptr

Test Plan:

cmake .. -DENABLE_SANITIZERS=address
ninja all check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7578

Details

Provenance
majcostaAuthored on Sep 24 2020, 18:33
majcostaPushed on Oct 1 2020, 00:23
Reviewer
Restricted Project
Differential Revision
D7578: [refactor] make the finalized BlockIndex* a private member of CChainState
Parents
rABCc6b38e8b94bb: [backport#17237 1/2] wallet: Lock address type in ReserveDestination
Branches
Unknown
Tags
Unknown