aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2022-11-18 11:32:49 -0500
committerAndrew Chow <github@achow101.com>2022-11-18 11:33:10 -0500
commitaeb395dcdbfe2b1a6c77ff218939a18afde3add9 (patch)
tree99b4c0206a822d0a7c46a70fdb3dc2ff3311ecef /src/init.cpp
parent256120d2da76e43c53a9fcc4e3a2333fd608a48b (diff)
parent6630a1e8448c633e4abaa8f5903f11cac6f433a7 (diff)
Merge bitcoin/bitcoin#25315: Add warning on first startup if free disk space is less than necessary
6630a1e8448c633e4abaa8f5903f11cac6f433a7 Add warning on first startup if free disk space is less than necessary (Ben Woosley) Pull request description: This reworks/revives https://github.com/bitcoin/bitcoin/pull/15848 to add a check for low disk space on first startup and issue a warning if disk space is below the expected space required to accommodate the blocks. This PR was fashioned by a team of developers at the [bitcoin++](https://www.btcplusplus.dev/) conference workshop: "[Let's contribute to Bitcoin Core](https://sched.co/12P6Z)" Fixes #15813 ACKs for top commit: achow101: ACK 6630a1e8448c633e4abaa8f5903f11cac6f433a7 willcl-ark: tACK 6630a1e8448c633e4abaa8f5903f11cac6f433a7 rebased on master. Warning shows on first start but not on restart after some blocks have been downloaded. aureleoules: ACK 6630a1e8448c633e4abaa8f5903f11cac6f433a7 pablomartin4btc: re-ACK https://github.com/bitcoin/bitcoin/commit/6630a1e8448c633e4abaa8f5903f11cac6f433a7 hernanmarino: ReACK https://github.com/bitcoin/bitcoin/commit/6630a1e8448c633e4abaa8f5903f11cac6f433a7 Tree-SHA512: 0f18acabdf2b514e96e2eea8f304960b952226b83dc91334cf7d1f6355ea2f257aaec0ee38d43ac36435385ecd918333d20657c35a8a7407e7cf2680ccb643bb
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 24659de3df..6f44ed6c3d 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1613,6 +1613,24 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
return false;
}
+ int chain_active_height = WITH_LOCK(cs_main, return chainman.ActiveChain().Height());
+
+ // On first startup, warn on low block storage space
+ if (!fReindex && !fReindexChainState && chain_active_height <= 1) {
+ uint64_t additional_bytes_needed = fPruneMode ? nPruneTarget
+ : chainparams.AssumedBlockchainSize() * 1024 * 1024 * 1024;
+
+ if (!CheckDiskSpace(args.GetBlocksDirPath(), additional_bytes_needed)) {
+ InitWarning(strprintf(_(
+ "Disk space for %s may not accommodate the block files. " \
+ "Approximately %u GB of data will be stored in this directory."
+ ),
+ fs::quoted(fs::PathToString(args.GetBlocksDirPath())),
+ chainparams.AssumedBlockchainSize()
+ ));
+ }
+ }
+
// Either install a handler to notify us when genesis activates, or set fHaveGenesis directly.
// No locking, as this happens before any background thread is started.
boost::signals2::connection block_notify_genesis_wait_connection;
@@ -1662,8 +1680,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// ********************************************************* Step 12: start node
- int chain_active_height;
-
//// debug print
{
LOCK(cs_main);