mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
validation: indexing changes for assumeutxo
When using an assumedvalid chainstate, only process validationinterface callbacks from the background chainstate within indexes. This ensures that all indexes are built in-order. Later, we can possibly designate indexes which can be built out of order and continue their operation during snapshot use. Once the background sync has completed, restart the indexes so that they continue to index the now-validated snapshot chainstate.
This commit is contained in:
committed by
James O'Beirne
parent
1fffdd76a1
commit
373cf91531
@@ -3289,6 +3289,16 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr<
|
||||
|
||||
if (WITH_LOCK(::cs_main, return m_disabled)) {
|
||||
// Background chainstate has reached the snapshot base block, so exit.
|
||||
|
||||
// Restart indexes to resume indexing for all blocks unique to the snapshot
|
||||
// chain. This resumes indexing "in order" from where the indexing on the
|
||||
// background validation chain left off.
|
||||
//
|
||||
// This cannot be done while holding cs_main (within
|
||||
// MaybeCompleteSnapshotValidation) or a cs_main deadlock will occur.
|
||||
if (m_chainman.restart_indexes) {
|
||||
m_chainman.restart_indexes();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5921,3 +5931,11 @@ bool ChainstateManager::ValidatedSnapshotCleanup()
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Chainstate& ChainstateManager::GetChainstateForIndexing()
|
||||
{
|
||||
// We can't always return `m_ibd_chainstate` because after background validation
|
||||
// has completed, `m_snapshot_chainstate == m_active_chainstate`, but it can be
|
||||
// indexed.
|
||||
return (this->GetAll().size() > 1) ? *m_ibd_chainstate : *m_active_chainstate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user