@@ -2440,8 +2440,6 @@ CoinsCacheSizeState CChainState::GetCoinsCacheSizeState(
24402440 int64_t nTotalSpace =
24412441 max_coins_cache_size_bytes + std::max<int64_t >(max_mempool_size_bytes - nMempoolUsage, 0 );
24422442
2443- cacheSize += evoDb->GetMemoryUsage ();
2444-
24452443 // ! No need to periodic flush if at least this much space still available.
24462444 static constexpr int64_t MAX_BLOCK_COINSDB_USAGE_BYTES = 10 * 1024 * 1024 ; // 10MB
24472445 int64_t large_threshold =
@@ -2509,12 +2507,14 @@ bool CChainState::FlushStateToDisk(
25092507 bool fCacheLarge = mode == FlushStateMode::PERIODIC && cache_state >= CoinsCacheSizeState::LARGE;
25102508 // The cache is over the limit, we have to write now.
25112509 bool fCacheCritical = mode == FlushStateMode::IF_NEEDED && cache_state >= CoinsCacheSizeState::CRITICAL;
2510+ // The evodb cache is too large
2511+ bool fEvoDbCacheCritical = mode == FlushStateMode::IF_NEEDED && evoDb != nullptr && evoDb->GetMemoryUsage () >= (64 << 20 );
25122512 // 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.
25132513 bool fPeriodicWrite = mode == FlushStateMode::PERIODIC && nNow > nLastWrite + DATABASE_WRITE_INTERVAL;
25142514 // It's been very long since we flushed the cache. Do this infrequently, to optimize cache usage.
25152515 bool fPeriodicFlush = mode == FlushStateMode::PERIODIC && nNow > nLastFlush + DATABASE_FLUSH_INTERVAL;
25162516 // Combine all conditions that result in a full cache flush.
2517- fDoFullFlush = (mode == FlushStateMode::ALWAYS) || fCacheLarge || fCacheCritical || fPeriodicFlush || fFlushForPrune ;
2517+ fDoFullFlush = (mode == FlushStateMode::ALWAYS) || fCacheLarge || fCacheCritical || fEvoDbCacheCritical || fPeriodicFlush || fFlushForPrune ;
25182518 // Write blocks and block index to disk.
25192519 if (fDoFullFlush || fPeriodicWrite ) {
25202520 // Depend on nMinDiskSpace to ensure we can write block index
0 commit comments