mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-17 17:02:43 +00:00
validation: periodically flush dbcache during reindex-chainstate
Move the periodic flush inside the outer loop of ActivateBestChain. For very long activations, such as with reindex-chainstate, this calls periodic flushes so progress can be saved to disk. Co-Authored-By: l0rinc <pap.lorinc@gmail.com>
This commit is contained in:
parent
eba5f9c4b6
commit
84820561dc
@ -3567,6 +3567,11 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr<
|
||||
m_chainman.MaybeRebalanceCaches();
|
||||
}
|
||||
|
||||
// Write changes periodically to disk, after relay.
|
||||
if (!FlushStateToDisk(state, FlushStateMode::PERIODIC)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (WITH_LOCK(::cs_main, return m_disabled)) {
|
||||
// Background chainstate has reached the snapshot base block, so exit.
|
||||
|
||||
@ -3591,11 +3596,6 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr<
|
||||
|
||||
m_chainman.CheckBlockIndex();
|
||||
|
||||
// Write changes periodically to disk, after relay.
|
||||
if (!FlushStateToDisk(state, FlushStateMode::PERIODIC)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user