diff --git a/src/kernel/blockmanager_opts.h b/src/kernel/blockmanager_opts.h index 5584a66e020..6fa9ddd8c9f 100644 --- a/src/kernel/blockmanager_opts.h +++ b/src/kernel/blockmanager_opts.h @@ -5,6 +5,8 @@ #ifndef BITCOIN_KERNEL_BLOCKMANAGER_OPTS_H #define BITCOIN_KERNEL_BLOCKMANAGER_OPTS_H +#include + class CChainParams; namespace kernel { @@ -16,6 +18,7 @@ namespace kernel { struct BlockManagerOpts { const CChainParams& chainparams; uint64_t prune_target{0}; + bool fast_prune{false}; }; } // namespace kernel diff --git a/src/node/blockmanager_args.cpp b/src/node/blockmanager_args.cpp index 9c320243e15..179c3a46044 100644 --- a/src/node/blockmanager_args.cpp +++ b/src/node/blockmanager_args.cpp @@ -31,6 +31,8 @@ std::optional ApplyArgsManOptions(const ArgsManager& args, BlockM } opts.prune_target = nPruneTarget; + if (auto value{args.GetBoolArg("-fastprune")}) opts.fast_prune = *value; + return std::nullopt; } } // namespace node diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index 7fc61444e51..a6758b8fc9c 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -581,7 +581,7 @@ void BlockManager::UnlinkPrunedFiles(const std::set& setFilesToPrune) const FlatFileSeq BlockManager::BlockFileSeq() const { - return FlatFileSeq(gArgs.GetBlocksDirPath(), "blk", gArgs.GetBoolArg("-fastprune", false) ? 0x4000 /* 16kb */ : BLOCKFILE_CHUNK_SIZE); + return FlatFileSeq(gArgs.GetBlocksDirPath(), "blk", m_opts.fast_prune ? 0x4000 /* 16kb */ : BLOCKFILE_CHUNK_SIZE); } FlatFileSeq BlockManager::UndoFileSeq() const @@ -619,7 +619,7 @@ bool BlockManager::FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigne unsigned int max_blockfile_size{MAX_BLOCKFILE_SIZE}; // Use smaller blockfiles in test-only -fastprune mode - but avoid // the possibility of having a block not fit into the block file. - if (gArgs.GetBoolArg("-fastprune", false)) { + if (m_opts.fast_prune) { max_blockfile_size = 0x10000; // 64kiB if (nAddSize >= max_blockfile_size) { // dynamically adjust the blockfile size to be larger than the added size