mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-23 14:10:15 +01: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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user