diff --git a/src/validation.cpp b/src/validation.cpp index 01722e70ec2..12e28cbbfbf 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2831,7 +2831,6 @@ bool Chainstate::FlushStateToDisk( try { { bool fFlushForPrune = false; - bool fDoFullFlush = false; CoinsCacheSizeState cache_state = GetCoinsCacheSizeState(); LOCK(m_blockman.cs_LastBlockFile); @@ -2887,10 +2886,10 @@ bool Chainstate::FlushStateToDisk( bool fCacheCritical = mode == FlushStateMode::IF_NEEDED && cache_state >= CoinsCacheSizeState::CRITICAL; // It's been a while since we wrote the block index and chain state to disk. Do this frequently, so we don't need to redownload or reindex after a crash. bool fPeriodicWrite = mode == FlushStateMode::PERIODIC && nNow > m_last_write + DATABASE_WRITE_INTERVAL; - // Combine all conditions that result in a full cache flush. - fDoFullFlush = (mode == FlushStateMode::ALWAYS) || fCacheLarge || fCacheCritical || fPeriodicWrite || fFlushForPrune; + // Combine all conditions that result in a write to disk. + bool should_write = (mode == FlushStateMode::ALWAYS) || fCacheLarge || fCacheCritical || fPeriodicWrite || fFlushForPrune; // Write blocks, block index and best chain related state to disk. - if (fDoFullFlush) { + if (should_write) { // Ensure we can write block index if (!CheckDiskSpace(m_blockman.m_opts.blocks_dir)) { return FatalError(m_chainman.GetNotifications(), state, _("Disk space is too low!"));