mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Merge bitcoin/bitcoin#25315: Add warning on first startup if free disk space is less than necessary
6630a1e844
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: ACK6630a1e844
willcl-ark: tACK6630a1e844
rebased on master. Warning shows on first start but not on restart after some blocks have been downloaded. aureleoules: ACK6630a1e844
pablomartin4btc: re-ACK6630a1e844
hernanmarino: ReACK6630a1e844
Tree-SHA512: 0f18acabdf2b514e96e2eea8f304960b952226b83dc91334cf7d1f6355ea2f257aaec0ee38d43ac36435385ecd918333d20657c35a8a7407e7cf2680ccb643bb
This commit is contained in:
commit
aeb395dcdb
3 changed files with 22 additions and 6 deletions
20
src/init.cpp
20
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);
|
||||
|
|
|
@ -22,7 +22,7 @@ class RejectLowDifficultyHeadersTest(BitcoinTestFramework):
|
|||
self.setup_clean_chain = True
|
||||
self.chain = 'testnet3' # Use testnet chain because it has an early checkpoint
|
||||
self.num_nodes = 2
|
||||
self.extra_args = [["-minimumchainwork=0x0"], ["-minimumchainwork=0x0"]]
|
||||
self.extra_args = [["-minimumchainwork=0x0", '-prune=550']] * self.num_nodes
|
||||
|
||||
def add_options(self, parser):
|
||||
parser.add_argument(
|
||||
|
@ -63,7 +63,7 @@ class RejectLowDifficultyHeadersTest(BitcoinTestFramework):
|
|||
|
||||
self.log.info("Feed all fork headers (succeeds without checkpoint)")
|
||||
# On node 0 it succeeds because checkpoints are disabled
|
||||
self.restart_node(0, extra_args=['-nocheckpoints', "-minimumchainwork=0x0"])
|
||||
self.restart_node(0, extra_args=['-nocheckpoints', "-minimumchainwork=0x0", '-prune=550'])
|
||||
peer_no_checkpoint = self.nodes[0].add_p2p_connection(P2PInterface())
|
||||
peer_no_checkpoint.send_and_ping(msg_headers(self.headers_fork))
|
||||
assert {
|
||||
|
|
|
@ -21,7 +21,7 @@ class WalletCrossChain(BitcoinTestFramework):
|
|||
|
||||
# Switch node 1 to testnet before starting it.
|
||||
self.nodes[1].chain = 'testnet3'
|
||||
self.nodes[1].extra_args = ['-maxconnections=0'] # disable testnet sync
|
||||
self.nodes[1].extra_args = ['-maxconnections=0', '-prune=550'] # disable testnet sync
|
||||
with open(self.nodes[1].bitcoinconf, 'r', encoding='utf8') as conf:
|
||||
conf_data = conf.read()
|
||||
with open (self.nodes[1].bitcoinconf, 'w', encoding='utf8') as conf:
|
||||
|
@ -51,7 +51,7 @@ class WalletCrossChain(BitcoinTestFramework):
|
|||
if not self.options.descriptors:
|
||||
self.log.info("Override cross-chain wallet load protection")
|
||||
self.stop_nodes()
|
||||
self.start_nodes([['-walletcrosschain']] * self.num_nodes)
|
||||
self.start_nodes([['-walletcrosschain', '-prune=550']] * self.num_nodes)
|
||||
self.nodes[0].loadwallet(node1_wallet)
|
||||
self.nodes[1].loadwallet(node0_wallet)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue