Improve docs about setting CBlockIndex hash fields

These fields have documented invariants, but comments in AddToBlockIndex are useful for review.
This commit is contained in:
str4d 2021-06-17 16:53:44 +01:00 committed by Jack Grigg
parent d7a517465b
commit da8fcedd4d
1 changed files with 8 additions and 5 deletions

View File

@ -3945,18 +3945,21 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block, const Consensus::Params&
pindexNew->nHeight = pindexNew->pprev->nHeight + 1;
if (consensusParams.NetworkUpgradeActive(pindexNew->nHeight, Consensus::UPGRADE_NU5)) {
// The following hashes are currently null, and will be set correctly in
// The following hashes will be null if this block has never been
// connected to a main chain; they will be (re)set correctly in
// ConnectBlock:
// - hashFinalSaplingRoot
// - hashFinalOrchardRoot
// - hashChainHistoryRoot
} else if (IsActivationHeight(pindexNew->nHeight, consensusParams, Consensus::UPGRADE_HEARTWOOD)) {
// hashFinalSaplingRoot and hashFinalOrchardRoot are currently null, and will
// be set correctly in ConnectBlock.
// hashFinalSaplingRoot and hashFinalOrchardRoot will be null if this block has
// never been connected to a main chain; they will be (re)set correctly in
// ConnectBlock.
// hashChainHistoryRoot is null.
} else if (consensusParams.NetworkUpgradeActive(pindexNew->nHeight, Consensus::UPGRADE_HEARTWOOD)) {
// hashFinalSaplingRoot and hashFinalOrchardRoot are currently null, and will
// be set correctly in ConnectBlock.
// hashFinalSaplingRoot and hashFinalOrchardRoot will be null if this block has
// never been connected to a main chain; they will be (re)set correctly in
// ConnectBlock.
pindexNew->hashChainHistoryRoot = pindexNew->hashBlockCommitments;
} else {
// hashFinalOrchardRoot and hashChainHistoryRoot are null.