Some follow-ups from #31405:
- avoid duplicate recalculation of failure flags and
m_best_header
inInvalidateBlock()
, which already does the accounting for these quantities while disconnecting blocks, so recalcuation is not needed in the finalInvalidChainFound
call (https://github.com/bitcoin/bitcoin/pull/31405#discussion_r2138368309) - make it clearer that all block indexes with a
CBlockIndexWorkComparator
score at least as good as the tip (and no others) are expected insetBlockIndexCandidates
. People think ofnChainWork
when the termwork
is used and not of the (slightly arbitrary)CBlockIndexWorkComparator
tiebreaker rules, which makes the current documentation imprecise ( #31405 (review) ) - add a comment that
nChainWork
, notCBlockIndexWorkComparator
is used form_best_header
(https://github.com/bitcoin/bitcoin/pull/31405#discussion_r2138368441)