@@ -2360,8 +2360,6 @@ bool Chainstate::FlushStateToDisk(
2360
2360
{
2361
2361
LOCK (cs_main);
2362
2362
assert (this ->CanFlushToDisk ());
2363
- static std::chrono::microseconds nLastWrite{0 };
2364
- static std::chrono::microseconds nLastFlush{0 };
2365
2363
std::set<int > setFilesToPrune;
2366
2364
bool full_flush_completed = false ;
2367
2365
@@ -2415,20 +2413,20 @@ bool Chainstate::FlushStateToDisk(
2415
2413
}
2416
2414
const auto nNow = GetTime<std::chrono::microseconds>();
2417
2415
// Avoid writing/flushing immediately after startup.
2418
- if (nLastWrite .count () == 0 ) {
2419
- nLastWrite = nNow;
2416
+ if (m_last_write .count () == 0 ) {
2417
+ m_last_write = nNow;
2420
2418
}
2421
- if (nLastFlush .count () == 0 ) {
2422
- nLastFlush = nNow;
2419
+ if (m_last_flush .count () == 0 ) {
2420
+ m_last_flush = nNow;
2423
2421
}
2424
2422
// 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).
2425
2423
bool fCacheLarge = mode == FlushStateMode::PERIODIC && cache_state >= CoinsCacheSizeState::LARGE;
2426
2424
// The cache is over the limit, we have to write now.
2427
2425
bool fCacheCritical = mode == FlushStateMode::IF_NEEDED && cache_state >= CoinsCacheSizeState::CRITICAL;
2428
2426
// 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.
2429
- bool fPeriodicWrite = mode == FlushStateMode::PERIODIC && nNow > nLastWrite + DATABASE_WRITE_INTERVAL;
2427
+ bool fPeriodicWrite = mode == FlushStateMode::PERIODIC && nNow > m_last_write + DATABASE_WRITE_INTERVAL;
2430
2428
// It's been very long since we flushed the cache. Do this infrequently, to optimize cache usage.
2431
- bool fPeriodicFlush = mode == FlushStateMode::PERIODIC && nNow > nLastFlush + DATABASE_FLUSH_INTERVAL;
2429
+ bool fPeriodicFlush = mode == FlushStateMode::PERIODIC && nNow > m_last_flush + DATABASE_FLUSH_INTERVAL;
2432
2430
// Combine all conditions that result in a full cache flush.
2433
2431
fDoFullFlush = (mode == FlushStateMode::ALWAYS) || fCacheLarge || fCacheCritical || fPeriodicFlush || fFlushForPrune ;
2434
2432
// Write blocks and block index to disk.
@@ -2458,7 +2456,7 @@ bool Chainstate::FlushStateToDisk(
2458
2456
2459
2457
UnlinkPrunedFiles (setFilesToPrune);
2460
2458
}
2461
- nLastWrite = nNow;
2459
+ m_last_write = nNow;
2462
2460
}
2463
2461
// Flush best chain related state. This can only be done if the blocks / block index write was also done.
2464
2462
if (fDoFullFlush && !CoinsTip ().GetBestBlock ().IsNull ()) {
@@ -2476,7 +2474,7 @@ bool Chainstate::FlushStateToDisk(
2476
2474
// Flush the chainstate (which may refer to block index entries).
2477
2475
if (!CoinsTip ().Flush ())
2478
2476
return AbortNode (state, " Failed to write to coin database" );
2479
- nLastFlush = nNow;
2477
+ m_last_flush = nNow;
2480
2478
full_flush_completed = true ;
2481
2479
TRACE5 (utxocache, flush,
2482
2480
(int64_t )(GetTimeMicros () - nNow.count ()), // in microseconds (µs)
0 commit comments