Make nSequenceId init value constants

Make it easier to follow what the values come without having to go
over the comments, plus easier to maintain
This commit is contained in:
Sergi Delgado Segura
2025-01-28 12:12:36 -05:00
parent 8b91883a23
commit 18524b072e
4 changed files with 16 additions and 10 deletions

View File

@@ -4698,7 +4698,7 @@ bool Chainstate::LoadChainTip()
// to maintain a consistent best tip over reboots in case of a tie.
auto target = tip;
while (target) {
target->nSequenceId = 0;
target->nSequenceId = SEQ_ID_BEST_CHAIN_FROM_DISK;
target = target->pprev;
}
@@ -5357,7 +5357,9 @@ void ChainstateManager::CheckBlockIndex() const
}
}
}
if (!pindex->HaveNumChainTxs()) assert(pindex->nSequenceId <= 1); // nSequenceId can't be set higher than 1 for blocks that aren't linked (negative is used for preciousblock, 0 for active chain)
// nSequenceId can't be set higher than SEQ_ID_INIT_FROM_DISK{1} for blocks that aren't linked
// (negative is used for preciousblock, SEQ_ID_BEST_CHAIN_FROM_DISK{0} for active chain when loaded from disk)
if (!pindex->HaveNumChainTxs()) assert(pindex->nSequenceId <= SEQ_ID_INIT_FROM_DISK);
// VALID_TRANSACTIONS is equivalent to nTx > 0 for all nodes (whether or not pruning has occurred).
// HAVE_DATA is only equivalent to nTx > 0 (or VALID_TRANSACTIONS) if no pruning has occurred.
if (!m_blockman.m_have_pruned) {