Skip to content

Commit 53e9b71

Browse files
l0rincjonatack
andcommitted
log: print reason for why should_write was triggered in FlushStateToDisk
Co-authored-by: Jon Atack <[email protected]>
1 parent 2df824f commit 53e9b71

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/validation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,6 +2874,9 @@ bool Chainstate::FlushStateToDisk(
28742874
bool should_write = (mode == FlushStateMode::ALWAYS) || fCacheLarge || fCacheCritical || fPeriodicWrite || fFlushForPrune;
28752875
// Write blocks, block index and best chain related state to disk.
28762876
if (should_write) {
2877+
LogDebug(BCLog::COINDB, "Writing chainstate to disk: flush mode=%s, prune=%d, large=%d, critical=%d, periodic=%d",
2878+
FlushStateModeNames[size_t(mode)], fFlushForPrune, fCacheLarge, fCacheCritical, fPeriodicWrite);
2879+
28772880
// Ensure we can write block index
28782881
if (!CheckDiskSpace(m_blockman.m_opts.blocks_dir)) {
28792882
return FatalError(m_chainman.GetNotifications(), state, _("Disk space is too low!"));

src/validation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,8 @@ enum DisconnectResult
437437
class ConnectTrace;
438438

439439
/** @see Chainstate::FlushStateToDisk */
440-
enum class FlushStateMode {
440+
inline constexpr std::array FlushStateModeNames{"NONE", "IF_NEEDED", "PERIODIC", "ALWAYS"};
441+
enum class FlushStateMode: uint8_t {
441442
NONE,
442443
IF_NEEDED,
443444
PERIODIC,

0 commit comments

Comments
 (0)