@@ -2652,8 +2652,6 @@ bool CChainState::FlushStateToDisk(
26522652{
26532653 LOCK (cs_main);
26542654 assert (this ->CanFlushToDisk ());
2655- static std::chrono::microseconds nLastWrite{0 };
2656- static std::chrono::microseconds nLastFlush{0 };
26572655 std::set<int > setFilesToPrune;
26582656 bool full_flush_completed = false ;
26592657
@@ -2707,11 +2705,11 @@ bool CChainState::FlushStateToDisk(
27072705 }
27082706 const auto nNow = GetTime<std::chrono::microseconds>();
27092707 // Avoid writing/flushing immediately after startup.
2710- if (nLastWrite .count () == 0 ) {
2711- nLastWrite = nNow;
2708+ if (m_last_write .count () == 0 ) {
2709+ m_last_write = nNow;
27122710 }
2713- if (nLastFlush .count () == 0 ) {
2714- nLastFlush = nNow;
2711+ if (m_last_flush .count () == 0 ) {
2712+ m_last_flush = nNow;
27152713 }
27162714 // The cache is large and we're within 10% and 10 MiB of the limit, but we have time now (not in the middle of a block processing).
27172715 bool fCacheLarge = mode == FlushStateMode::PERIODIC && cache_state >= CoinsCacheSizeState::LARGE;
@@ -2720,9 +2718,9 @@ bool CChainState::FlushStateToDisk(
27202718 // The evodb cache is too large
27212719 bool fEvoDbCacheCritical = mode == FlushStateMode::IF_NEEDED && m_evoDb.GetMemoryUsage () >= (64 << 20 );
27222720 // It's been a while since we wrote the block index to disk. Do this frequently, so we don't need to redownload after a crash.
2723- bool fPeriodicWrite = mode == FlushStateMode::PERIODIC && nNow > nLastWrite + DATABASE_WRITE_INTERVAL;
2721+ bool fPeriodicWrite = mode == FlushStateMode::PERIODIC && nNow > m_last_write + DATABASE_WRITE_INTERVAL;
27242722 // It's been very long since we flushed the cache. Do this infrequently, to optimize cache usage.
2725- bool fPeriodicFlush = mode == FlushStateMode::PERIODIC && nNow > nLastFlush + DATABASE_FLUSH_INTERVAL;
2723+ bool fPeriodicFlush = mode == FlushStateMode::PERIODIC && nNow > m_last_flush + DATABASE_FLUSH_INTERVAL;
27262724 // Combine all conditions that result in a full cache flush.
27272725 fDoFullFlush = (mode == FlushStateMode::ALWAYS) || fCacheLarge || fCacheCritical || fEvoDbCacheCritical || fPeriodicFlush || fFlushForPrune ;
27282726 // Write blocks and block index to disk.
@@ -2753,7 +2751,7 @@ bool CChainState::FlushStateToDisk(
27532751
27542752 UnlinkPrunedFiles (setFilesToPrune);
27552753 }
2756- nLastWrite = nNow;
2754+ m_last_write = nNow;
27572755 }
27582756 // Flush best chain related state. This can only be done if the blocks / block index write was also done.
27592757 if (fDoFullFlush && !CoinsTip ().GetBestBlock ().IsNull ()) {
@@ -2779,7 +2777,7 @@ bool CChainState::FlushStateToDisk(
27792777 return AbortNode (state, " Failed to commit EvoDB" );
27802778 }
27812779 }
2782- nLastFlush = nNow;
2780+ m_last_flush = nNow;
27832781 full_flush_completed = true ;
27842782 TRACE5 (utxocache, flush,
27852783 (int64_t )(GetTimeMicros () - nNow.count ()), // in microseconds (µs)
0 commit comments