aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurèle Oulès <aurele@oules.com>2022-10-18 10:59:37 +0200
committerAurèle Oulès <aurele@oules.com>2022-10-19 10:41:15 +0200
commited52e71176fc97c6ed01e3eebd85acdec54b4448 (patch)
tree3e327df8fb7e6f093d0dfa7c2a80262f73be223c
parent7fe537f7a48675b1d25542bee6f390d665547580 (diff)
downloadbitcoin-ed52e71176fc97c6ed01e3eebd85acdec54b4448.tar.xz
Periodically check disk space to avoid corruption
-rw-r--r--src/init.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 8ffab64622..57646c3eeb 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -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