refactor: rename fDoFullFlush to should_write

This commit is contained in:
Andrew Toth 2024-08-31 11:14:18 -04:00
parent 7998eda034
commit a33aaadb2d
No known key found for this signature in database
GPG key ID: 60007AFC8938B018

View file

@ -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!"));