validation: don't erase coins cache on prune flushes

This commit is contained in:
Andrew Toth 2024-03-21 10:10:15 -04:00
parent 5c67229047
commit 499f1f029a
No known key found for this signature in database
GPG Key ID: 60007AFC8938B018
1 changed files with 3 additions and 1 deletions

View File

@ -2745,8 +2745,10 @@ bool Chainstate::FlushStateToDisk(
return FatalError(m_chainman.GetNotifications(), state, _("Disk space is too low!"));
}
// Flush the chainstate (which may refer to block index entries).
if (!CoinsTip().Flush())
const auto empty_cache{(mode == FlushStateMode::ALWAYS) || fCacheLarge || fCacheCritical || fPeriodicFlush};
if (empty_cache ? !CoinsTip().Flush() : !CoinsTip().Sync()) {
return FatalError(m_chainman.GetNotifications(), state, _("Failed to write to coin database."));
}
m_last_flush = nNow;
full_flush_completed = true;
TRACE5(utxocache, flush,