Skip to content

Commit ed52e71

Browse files
committed
Periodically check disk space to avoid corruption
1 parent 7fe537f commit ed52e71

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/init.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,15 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
11591159
RandAddPeriodic();
11601160
}, std::chrono::minutes{1});
11611161

1162+
// Check disk space every 5 minutes to avoid db corruption.
1163+
node.scheduler->scheduleEvery([&args]{
1164+
constexpr uint64_t min_disk_space = 50 << 20; // 50 MB
1165+
if (!CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space)) {
1166+
LogPrintf("Shutting down due to lack of disk space!\n");
1167+
StartShutdown();
1168+
}
1169+
}, std::chrono::minutes{5});
1170+
11621171
GetMainSignals().RegisterBackgroundSignalScheduler(*node.scheduler);
11631172

11641173
// Create client interfaces for wallets that are supposed to be loaded

0 commit comments

Comments
 (0)