mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
validation: populate nChainTx value for assumedvalid chainstates
Use the expected AssumeutxoData in order to bootstrap nChainTx values for assumedvalid blockindex entries in the snapshot chainstate. This is necessary because nChainTx is normally built up from nTx values, which are populated using blockdata which the snapshot chainstate does not yet have.
This commit is contained in:
parent
49ef778158
commit
4c3b8ca35c
3 changed files with 29 additions and 7 deletions
|
|
@ -4542,7 +4542,7 @@ bool ChainstateManager::LoadBlockIndex()
|
|||
// Load block index from databases
|
||||
bool needs_init = fReindex;
|
||||
if (!fReindex) {
|
||||
bool ret{m_blockman.LoadBlockIndexDB()};
|
||||
bool ret{m_blockman.LoadBlockIndexDB(SnapshotBlockhash())};
|
||||
if (!ret) return false;
|
||||
|
||||
m_blockman.ScanAndUnlinkAlreadyPrunedFiles();
|
||||
|
|
@ -4838,6 +4838,10 @@ void ChainstateManager::CheckBlockIndex()
|
|||
CBlockIndex* pindexFirstAssumeValid = nullptr; // Oldest ancestor of pindex which has BLOCK_ASSUMED_VALID
|
||||
while (pindex != nullptr) {
|
||||
nNodes++;
|
||||
if (pindex->pprev && pindex->nTx > 0) {
|
||||
// nChainTx should increase monotonically
|
||||
assert(pindex->pprev->nChainTx <= pindex->nChainTx);
|
||||
}
|
||||
if (pindexFirstAssumeValid == nullptr && pindex->nStatus & BLOCK_ASSUMED_VALID) pindexFirstAssumeValid = pindex;
|
||||
if (pindexFirstInvalid == nullptr && pindex->nStatus & BLOCK_FAILED_VALID) pindexFirstInvalid = pindex;
|
||||
if (pindexFirstMissing == nullptr && !(pindex->nStatus & BLOCK_HAVE_DATA)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue