Skip to content

Commit

Permalink
Periodically check disk space to avoid corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
aureleoules committed Oct 19, 2022
1 parent 7fe537f commit ed52e71
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,15 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
RandAddPeriodic();
}, std::chrono::minutes{1});

// Check disk space every 5 minutes to avoid db corruption.
node.scheduler->scheduleEvery([&args]{
constexpr uint64_t min_disk_space = 50 << 20; // 50 MB
if (!CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space)) {
LogPrintf("Shutting down due to lack of disk space!\n");
StartShutdown();
}
}, std::chrono::minutes{5});

GetMainSignals().RegisterBackgroundSignalScheduler(*node.scheduler);

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

0 comments on commit ed52e71

Please sign in to comment.