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:
1 parent
eba5f9c4b6
commit
84820561dc
1 file changed
+5
-5
+5
-5
@@ -3567,6 +3567,11 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr<
|
|||||||
m_chainman.MaybeRebalanceCaches();
|
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)) {
|
if (WITH_LOCK(::cs_main, return m_disabled)) {
|
||||||
// Background chainstate has reached the snapshot base block, so exit.
|
// 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();
|
m_chainman.CheckBlockIndex();
|
||||||
|
|
||||||
// Write changes periodically to disk, after relay.
|
|
||||||
if (!FlushStateToDisk(state, FlushStateMode::PERIODIC)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user