From 4a6d1d1e3bc3d559cd13d134b4b827f22635ac4b Mon Sep 17 00:00:00 2001 From: Andrew Toth Date: Thu, 17 Aug 2023 16:17:18 -0400 Subject: [PATCH] validation: don't clear cache on periodic flush --- src/validation.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index 5c585438d14..94c470ce2cc 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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 || fFlushForPrune}; + 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,