mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
blockstorage: segment normal/assumedvalid blockfiles
When using an assumedvalid (snapshot) chainstate along with a background chainstate, we are syncing two very different regions of the chain simultaneously. If we use the same blockfile space for both of these syncs, wildly different height blocks will be stored alongside one another, making pruning ineffective. This change implements a separate blockfile cursor for the assumedvalid chainstate when one is in use.
This commit is contained in:
parent
4c3b8ca35c
commit
7fcd21544a
3 changed files with 179 additions and 47 deletions
|
|
@ -2601,7 +2601,7 @@ bool Chainstate::FlushStateToDisk(
|
|||
// First make sure all block and undo data is flushed to disk.
|
||||
// TODO: Handle return error, or add detailed comment why it is
|
||||
// safe to not return an error upon failure.
|
||||
if (!m_blockman.FlushBlockFile()) {
|
||||
if (!m_blockman.FlushChainstateBlockFile(m_chain.Height())) {
|
||||
LogPrintLevel(BCLog::VALIDATION, BCLog::Level::Warning, "%s: Failed to flush block file.\n", __func__);
|
||||
}
|
||||
}
|
||||
|
|
@ -5269,6 +5269,7 @@ bool ChainstateManager::ActivateSnapshot(
|
|||
assert(chaintip_loaded);
|
||||
|
||||
m_active_chainstate = m_snapshot_chainstate.get();
|
||||
m_blockman.m_snapshot_height = this->GetSnapshotBaseHeight();
|
||||
|
||||
LogPrintf("[snapshot] successfully activated snapshot %s\n", base_blockhash.ToString());
|
||||
LogPrintf("[snapshot] (%.2f MB)\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue