aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2023-03-15 18:39:01 -0400
committerAndrew Chow <github@achow101.com>2023-03-15 18:52:35 -0400
commitcbfbf46e57ebfb189da8623b51be58bb163e76b9 (patch)
tree84e36f446f150aa28f48829c9324d4c09c2ef011
parent8c4958bd4c06026dc108bc7f5f063d1f389d279b (diff)
parentfadf8b818226dc60adf88e927160f9c9680473a4 (diff)
Merge bitcoin/bitcoin#25781: Remove almost all blockstorage globals
fadf8b818226dc60adf88e927160f9c9680473a4 refactor: Add and use PRUNE_TARGET_MANUAL constexpr (MarcoFalke) fa9bd7be472f49b15f5f87711094095954322635 Move ::fImporting to BlockManager (MarcoFalke) fa442b137764e0b6c0d991ba641e90c3217be1bf Pass fImporting to ImportingNow helper class (MarcoFalke) fa177d7b6b3ad008d442ff9622c9b30e68d6e388 Move ::fPruneMode into BlockManager (MarcoFalke) fa721f1cab0de239a93f6bf70e3a8af26fddae8a Move ::nPruneTarget into BlockManager (MarcoFalke) Pull request description: It seems preferable to assign globals to a class (in this case `BlockManager`), than to leave them dangling. This should clarify scope for code-readers, as well as clarifying unit test behaviour. ACKs for top commit: TheCharlatan: Code review ACK fadf8b818226dc60adf88e927160f9c9680473a4 achow101: ACK fadf8b818226dc60adf88e927160f9c9680473a4 dergoegge: Code review ACK fadf8b818226dc60adf88e927160f9c9680473a4 Tree-SHA512: d261b69257560c9f460bbe85944ca478d0390b498a5af514bafcb4f6444841e5ea58c2e8982f38c48685d6f649039234aec853a934e24ebf23e20d975991a5dc
-rw-r--r--src/Makefile.am3
-rw-r--r--src/bitcoin-chainstate.cpp2
-rw-r--r--src/init.cpp28
-rw-r--r--src/kernel/blockmanager_opts.h20
-rw-r--r--src/node/blockmanager_args.cpp30
-rw-r--r--src/node/blockmanager_args.h20
-rw-r--r--src/node/blockstorage.cpp46
-rw-r--r--src/node/blockstorage.h26
-rw-r--r--src/node/chainstate.cpp2
-rw-r--r--src/node/interfaces.cpp2
-rw-r--r--src/rpc/blockchain.cpp4
-rw-r--r--src/test/blockmanager_tests.cpp2
-rw-r--r--src/test/util/setup_common.cpp2
-rw-r--r--src/test/validation_chainstatemanager_tests.cpp6
-rw-r--r--src/validation.cpp4
-rw-r--r--src/validation.h2
16 files changed, 135 insertions, 64 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index a0c1670287..68ec92b27f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -174,6 +174,7 @@ BITCOIN_CORE_H = \
interfaces/ipc.h \
interfaces/node.h \
interfaces/wallet.h \
+ kernel/blockmanager_opts.h \
kernel/chain.h \
kernel/chainstatemanager_opts.h \
kernel/checks.h \
@@ -200,6 +201,7 @@ BITCOIN_CORE_H = \
netbase.h \
netgroup.h \
netmessagemaker.h \
+ node/blockmanager_args.h \
node/blockstorage.h \
node/caches.h \
node/chainstate.h \
@@ -387,6 +389,7 @@ libbitcoin_node_a_SOURCES = \
net.cpp \
net_processing.cpp \
netgroup.cpp \
+ node/blockmanager_args.cpp \
node/blockstorage.cpp \
node/caches.cpp \
node/chainstate.cpp \
diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp
index 423fa79c6f..136904a0c0 100644
--- a/src/bitcoin-chainstate.cpp
+++ b/src/bitcoin-chainstate.cpp
@@ -85,7 +85,7 @@ int main(int argc, char* argv[])
.datadir = gArgs.GetDataDirNet(),
.adjusted_time_callback = NodeClock::now,
};
- ChainstateManager chainman{chainman_opts};
+ ChainstateManager chainman{chainman_opts, {}};
node::CacheSizes cache_sizes;
cache_sizes.block_tree_db = 2 << 20;
diff --git a/src/init.cpp b/src/init.cpp
index 090a11a825..8a45c38ce3 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -37,6 +37,7 @@
#include <net_processing.h>
#include <netbase.h>
#include <netgroup.h>
+#include <node/blockmanager_args.h>
#include <node/blockstorage.h>
#include <node/caches.h>
#include <node/chainstate.h>
@@ -122,9 +123,7 @@ using node::ShouldPersistMempool;
using node::NodeContext;
using node::ThreadImport;
using node::VerifyLoadedChainstate;
-using node::fPruneMode;
using node::fReindex;
-using node::nPruneTarget;
static constexpr bool DEFAULT_PROXYRANDOMIZE{true};
static constexpr bool DEFAULT_REST_ENABLE{false};
@@ -945,22 +944,6 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
init::SetLoggingCategories(args);
init::SetLoggingLevel(args);
- // block pruning; get the amount of disk space (in MiB) to allot for block & undo files
- int64_t nPruneArg = args.GetIntArg("-prune", 0);
- if (nPruneArg < 0) {
- return InitError(_("Prune cannot be configured with a negative value."));
- }
- nPruneTarget = (uint64_t) nPruneArg * 1024 * 1024;
- if (nPruneArg == 1) { // manual pruning: -prune=1
- nPruneTarget = std::numeric_limits<uint64_t>::max();
- fPruneMode = true;
- } else if (nPruneTarget) {
- if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
- return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
- }
- fPruneMode = true;
- }
-
nConnectTimeout = args.GetIntArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
if (nConnectTimeout <= 0) {
nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
@@ -1051,6 +1034,10 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
if (const auto error{ApplyArgsManOptions(args, chainman_opts_dummy)}) {
return InitError(*error);
}
+ node::BlockManager::Options blockman_opts_dummy{};
+ if (const auto error{ApplyArgsManOptions(args, blockman_opts_dummy)}) {
+ return InitError(*error);
+ }
}
return true;
@@ -1450,6 +1437,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
};
Assert(!ApplyArgsManOptions(args, chainman_opts)); // no error can happen, already checked in AppInitParameterInteraction
+ node::BlockManager::Options blockman_opts{};
+ Assert(!ApplyArgsManOptions(args, blockman_opts)); // no error can happen, already checked in AppInitParameterInteraction
+
// cache size calculations
CacheSizes cache_sizes = CalculateCacheSizes(args, g_enabled_filter_types.size());
@@ -1485,7 +1475,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
for (bool fLoaded = false; !fLoaded && !ShutdownRequested();) {
node.mempool = std::make_unique<CTxMemPool>(mempool_opts);
- node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
+ node.chainman = std::make_unique<ChainstateManager>(chainman_opts, blockman_opts);
ChainstateManager& chainman = *node.chainman;
node::ChainstateLoadOptions options;
diff --git a/src/kernel/blockmanager_opts.h b/src/kernel/blockmanager_opts.h
new file mode 100644
index 0000000000..9dc93b6dd2
--- /dev/null
+++ b/src/kernel/blockmanager_opts.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2022 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_KERNEL_BLOCKMANAGER_OPTS_H
+#define BITCOIN_KERNEL_BLOCKMANAGER_OPTS_H
+
+namespace kernel {
+
+/**
+ * An options struct for `BlockManager`, more ergonomically referred to as
+ * `BlockManager::Options` due to the using-declaration in `BlockManager`.
+ */
+struct BlockManagerOpts {
+ uint64_t prune_target{0};
+};
+
+} // namespace kernel
+
+#endif // BITCOIN_KERNEL_BLOCKMANAGER_OPTS_H
diff --git a/src/node/blockmanager_args.cpp b/src/node/blockmanager_args.cpp
new file mode 100644
index 0000000000..5fb5c8beed
--- /dev/null
+++ b/src/node/blockmanager_args.cpp
@@ -0,0 +1,30 @@
+// Copyright (c) 2023 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <node/blockmanager_args.h>
+
+#include <util/system.h>
+#include <validation.h>
+
+namespace node {
+std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& args, BlockManager::Options& opts)
+{
+ // block pruning; get the amount of disk space (in MiB) to allot for block & undo files
+ int64_t nPruneArg{args.GetIntArg("-prune", opts.prune_target)};
+ if (nPruneArg < 0) {
+ return _("Prune cannot be configured with a negative value.");
+ }
+ uint64_t nPruneTarget{uint64_t(nPruneArg) * 1024 * 1024};
+ if (nPruneArg == 1) { // manual pruning: -prune=1
+ nPruneTarget = BlockManager::PRUNE_TARGET_MANUAL;
+ } else if (nPruneTarget) {
+ if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
+ return strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024);
+ }
+ }
+ opts.prune_target = nPruneTarget;
+
+ return std::nullopt;
+}
+} // namespace node
diff --git a/src/node/blockmanager_args.h b/src/node/blockmanager_args.h
new file mode 100644
index 0000000000..e657c6bb45
--- /dev/null
+++ b/src/node/blockmanager_args.h
@@ -0,0 +1,20 @@
+
+// Copyright (c) 2023 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_NODE_BLOCKMANAGER_ARGS_H
+#define BITCOIN_NODE_BLOCKMANAGER_ARGS_H
+
+#include <node/blockstorage.h>
+
+#include <optional>
+
+class ArgsManager;
+struct bilingual_str;
+
+namespace node {
+std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& args, BlockManager::Options& opts);
+} // namespace node
+
+#endif // BITCOIN_NODE_BLOCKMANAGER_ARGS_H
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index 255b73b347..4356fc2b2a 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -26,10 +26,7 @@
#include <unordered_map>
namespace node {
-std::atomic_bool fImporting(false);
std::atomic_bool fReindex(false);
-bool fPruneMode = false;
-uint64_t nPruneTarget = 0;
bool CBlockIndexWorkComparator::operator()(const CBlockIndex* pa, const CBlockIndex* pb) const
{
@@ -154,7 +151,7 @@ void BlockManager::PruneOneBlockFile(const int fileNumber)
void BlockManager::FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight, int chain_tip_height)
{
- assert(fPruneMode && nManualPruneHeight > 0);
+ assert(IsPruneMode() && nManualPruneHeight > 0);
LOCK2(cs_main, cs_LastBlockFile);
if (chain_tip_height < 0) {
@@ -178,7 +175,7 @@ void BlockManager::FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nM
void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight, int chain_tip_height, int prune_height, bool is_ibd)
{
LOCK2(cs_main, cs_LastBlockFile);
- if (chain_tip_height < 0 || nPruneTarget == 0) {
+ if (chain_tip_height < 0 || GetPruneTarget() == 0) {
return;
}
if ((uint64_t)chain_tip_height <= nPruneAfterHeight) {
@@ -194,14 +191,14 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
uint64_t nBytesToPrune;
int count = 0;
- if (nCurrentUsage + nBuffer >= nPruneTarget) {
+ if (nCurrentUsage + nBuffer >= GetPruneTarget()) {
// On a prune event, the chainstate DB is flushed.
// To avoid excessive prune events negating the benefit of high dbcache
// values, we should not prune too rapidly.
// So when pruning in IBD, increase the buffer a bit to avoid a re-prune too soon.
if (is_ibd) {
// Since this is only relevant during IBD, we use a fixed 10%
- nBuffer += nPruneTarget / 10;
+ nBuffer += GetPruneTarget() / 10;
}
for (int fileNumber = 0; fileNumber < m_last_blockfile; fileNumber++) {
@@ -211,7 +208,7 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
continue;
}
- if (nCurrentUsage + nBuffer < nPruneTarget) { // are we below our target?
+ if (nCurrentUsage + nBuffer < GetPruneTarget()) { // are we below our target?
break;
}
@@ -229,9 +226,9 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
}
LogPrint(BCLog::PRUNE, "target=%dMiB actual=%dMiB diff=%dMiB max_prune_height=%d removed %d blk/rev pairs\n",
- nPruneTarget/1024/1024, nCurrentUsage/1024/1024,
- ((int64_t)nPruneTarget - (int64_t)nCurrentUsage)/1024/1024,
- nLastBlockWeCanPrune, count);
+ GetPruneTarget() / 1024 / 1024, nCurrentUsage / 1024 / 1024,
+ (int64_t(GetPruneTarget()) - int64_t(nCurrentUsage)) / 1024 / 1024,
+ nLastBlockWeCanPrune, count);
}
void BlockManager::UpdatePruneLock(const std::string& name, const PruneLockInfo& lock_info) {
@@ -657,7 +654,7 @@ bool BlockManager::FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigne
if (out_of_space) {
return AbortNode("Disk space is too low!", _("Disk space is too low!"));
}
- if (bytes_allocated != 0 && fPruneMode) {
+ if (bytes_allocated != 0 && IsPruneMode()) {
m_check_for_pruning = true;
}
}
@@ -681,7 +678,7 @@ bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFileP
if (out_of_space) {
return AbortNode(state, "Disk space is too low!", _("Disk space is too low!"));
}
- if (bytes_allocated != 0 && fPruneMode) {
+ if (bytes_allocated != 0 && IsPruneMode()) {
m_check_for_pruning = true;
}
@@ -846,17 +843,20 @@ FlatFilePos BlockManager::SaveBlockToDisk(const CBlock& block, int nHeight, CCha
return blockPos;
}
-struct CImportingNow {
- CImportingNow()
+class ImportingNow
+{
+ std::atomic<bool>& m_importing;
+
+public:
+ ImportingNow(std::atomic<bool>& importing) : m_importing{importing}
{
- assert(fImporting == false);
- fImporting = true;
+ assert(m_importing == false);
+ m_importing = true;
}
-
- ~CImportingNow()
+ ~ImportingNow()
{
- assert(fImporting == true);
- fImporting = false;
+ assert(m_importing == true);
+ m_importing = false;
}
};
@@ -866,7 +866,7 @@ void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFile
ScheduleBatchPriority();
{
- CImportingNow imp;
+ ImportingNow imp{chainman.m_blockman.m_importing};
// -reindex
if (fReindex) {
@@ -932,7 +932,7 @@ void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFile
StartShutdown();
return;
}
- } // End scope of CImportingNow
+ } // End scope of ImportingNow
chainman.ActiveChainstate().LoadMempool(mempool_path);
}
} // namespace node
diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h
index 09aff7f08b..5ba0045b8b 100644
--- a/src/node/blockstorage.h
+++ b/src/node/blockstorage.h
@@ -8,6 +8,7 @@
#include <attributes.h>
#include <chain.h>
#include <fs.h>
+#include <kernel/blockmanager_opts.h>
#include <kernel/cs_main.h>
#include <protocol.h>
#include <sync.h>
@@ -46,10 +47,7 @@ static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
/** Size of header written by WriteBlockToDisk before a serialized CBlock */
static constexpr size_t BLOCK_SERIALIZATION_HEADER_SIZE = CMessageHeader::MESSAGE_START_SIZE + sizeof(unsigned int);
-extern std::atomic_bool fImporting;
extern std::atomic_bool fReindex;
-extern bool fPruneMode;
-extern uint64_t nPruneTarget;
// Because validation code takes pointers to the map's CBlockIndex objects, if
// we ever switch to another associative container, we need to either use a
@@ -124,6 +122,8 @@ private:
*/
bool m_check_for_pruning = false;
+ const bool m_prune_mode;
+
/** Dirty block index entries. */
std::set<CBlockIndex*> m_dirty_blockindex;
@@ -138,7 +138,17 @@ private:
*/
std::unordered_map<std::string, PruneLockInfo> m_prune_locks GUARDED_BY(::cs_main);
+ const kernel::BlockManagerOpts m_opts;
+
public:
+ using Options = kernel::BlockManagerOpts;
+
+ explicit BlockManager(Options opts)
+ : m_prune_mode{opts.prune_target > 0},
+ m_opts{std::move(opts)} {};
+
+ std::atomic<bool> m_importing{false};
+
BlockMap m_block_index GUARDED_BY(cs_main);
std::vector<CBlockIndex*> GetAllBlockIndices() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
@@ -181,15 +191,13 @@ public:
FlatFilePos SaveBlockToDisk(const CBlock& block, int nHeight, CChain& active_chain, const CChainParams& chainparams, const FlatFilePos* dbp);
/** Whether running in -prune mode. */
- [[nodiscard]] bool IsPruneMode() const { return fPruneMode; }
+ [[nodiscard]] bool IsPruneMode() const { return m_prune_mode; }
/** Attempt to stay below this number of bytes of block files. */
- [[nodiscard]] uint64_t GetPruneTarget() const { return nPruneTarget; }
+ [[nodiscard]] uint64_t GetPruneTarget() const { return m_opts.prune_target; }
+ static constexpr auto PRUNE_TARGET_MANUAL{std::numeric_limits<uint64_t>::max()};
- [[nodiscard]] bool LoadingBlocks() const
- {
- return fImporting || fReindex;
- }
+ [[nodiscard]] bool LoadingBlocks() const { return m_importing || fReindex; }
/** Calculate the amount of disk space the block & undo files currently use */
uint64_t CalculateCurrentUsage();
diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp
index 125d6de5a5..cfd3472592 100644
--- a/src/node/chainstate.cpp
+++ b/src/node/chainstate.cpp
@@ -169,7 +169,7 @@ ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSize
if (chainman.MinimumChainWork() < UintToArith256(chainman.GetConsensus().nMinimumChainWork)) {
LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainman.GetConsensus().nMinimumChainWork.GetHex());
}
- if (chainman.m_blockman.GetPruneTarget() == std::numeric_limits<uint64_t>::max()) {
+ if (chainman.m_blockman.GetPruneTarget() == BlockManager::PRUNE_TARGET_MANUAL) {
LogPrintf("Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
} else if (chainman.m_blockman.GetPruneTarget()) {
LogPrintf("Prune configured to target %u MiB on disk for block and undo files.\n", chainman.m_blockman.GetPruneTarget() / 1024 / 1024);
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index 54aa21e984..b397661df4 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -295,7 +295,7 @@ public:
bool isInitialBlockDownload() override {
return chainman().ActiveChainstate().IsInitialBlockDownload();
}
- bool isLoadingBlocks() override { return node::fReindex || node::fImporting; }
+ bool isLoadingBlocks() override { return chainman().m_blockman.LoadingBlocks(); }
void setNetworkActive(bool active) override
{
if (m_context->connman) {
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 5afa460075..1a9b265fbe 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -1249,7 +1249,6 @@ RPCHelpMan getblockchaininfo()
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
- const ArgsManager& args{EnsureAnyArgsman(request.context)};
ChainstateManager& chainman = EnsureAnyChainman(request.context);
LOCK(cs_main);
Chainstate& active_chainstate = chainman.ActiveChainstate();
@@ -1272,8 +1271,7 @@ RPCHelpMan getblockchaininfo()
if (chainman.m_blockman.IsPruneMode()) {
obj.pushKV("pruneheight", chainman.m_blockman.GetFirstStoredBlock(tip)->nHeight);
- // if 0, execution bypasses the whole if block.
- bool automatic_pruning{args.GetIntArg("-prune", 0) != 1};
+ const bool automatic_pruning{chainman.m_blockman.GetPruneTarget() != BlockManager::PRUNE_TARGET_MANUAL};
obj.pushKV("automatic_pruning", automatic_pruning);
if (automatic_pruning) {
obj.pushKV("prune_target_size", chainman.m_blockman.GetPruneTarget());
diff --git a/src/test/blockmanager_tests.cpp b/src/test/blockmanager_tests.cpp
index d5825d0d7e..2118f476cd 100644
--- a/src/test/blockmanager_tests.cpp
+++ b/src/test/blockmanager_tests.cpp
@@ -21,7 +21,7 @@ BOOST_FIXTURE_TEST_SUITE(blockmanager_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(blockmanager_find_block_pos)
{
const auto params {CreateChainParams(ArgsManager{}, CBaseChainParams::MAIN)};
- BlockManager blockman {};
+ BlockManager blockman{{}};
CChain chain {};
// simulate adding a genesis block normally
BOOST_CHECK_EQUAL(blockman.SaveBlockToDisk(params->GenesisBlock(), 0, chain, *params, nullptr).nPos, BLOCK_SERIALIZATION_HEADER_SIZE);
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index 4e0000cb3d..58593c9d5b 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -184,7 +184,7 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
.adjusted_time_callback = GetAdjustedTime,
.check_block_index = true,
};
- m_node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
+ m_node.chainman = std::make_unique<ChainstateManager>(chainman_opts, node::BlockManager::Options{});
m_node.chainman->m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(DBParams{
.path = m_args.GetDataDirNet() / "blocks" / "index",
.cache_bytes = static_cast<size_t>(m_cache_sizes.block_tree_db),
diff --git a/src/test/validation_chainstatemanager_tests.cpp b/src/test/validation_chainstatemanager_tests.cpp
index 6fc9d0fa51..688aafdd46 100644
--- a/src/test/validation_chainstatemanager_tests.cpp
+++ b/src/test/validation_chainstatemanager_tests.cpp
@@ -381,7 +381,7 @@ struct SnapshotTestSetup : TestChain100Setup {
// For robustness, ensure the old manager is destroyed before creating a
// new one.
m_node.chainman.reset();
- m_node.chainman.reset(new ChainstateManager(chainman_opts));
+ m_node.chainman = std::make_unique<ChainstateManager>(chainman_opts, node::BlockManager::Options{});
}
return *Assert(m_node.chainman);
}
@@ -588,7 +588,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_snapshot_completion, SnapshotTestSetup
// chainstate_snapshot should still exist.
BOOST_CHECK(fs::exists(snapshot_chainstate_dir));
- // Test that simulating a shutdown (reseting ChainstateManager) and then performing
+ // Test that simulating a shutdown (resetting ChainstateManager) and then performing
// chainstate reinitializing successfully cleans up the background-validation
// chainstate data, and we end up with a single chainstate that is at tip.
ChainstateManager& chainman_restarted = this->SimulateNodeRestart();
@@ -660,7 +660,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_snapshot_completion_hash_mismatch, Sna
fs::path snapshot_invalid_dir = gArgs.GetDataDirNet() / "chainstate_snapshot_INVALID";
BOOST_CHECK(fs::exists(snapshot_invalid_dir));
- // Test that simulating a shutdown (reseting ChainstateManager) and then performing
+ // Test that simulating a shutdown (resetting ChainstateManager) and then performing
// chainstate reinitializing successfully loads only the fully-validated
// chainstate data, and we end up with a single chainstate that is at tip.
ChainstateManager& chainman_restarted = this->SimulateNodeRestart();
diff --git a/src/validation.cpp b/src/validation.cpp
index f3c0401c0f..47355b0850 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -5555,7 +5555,9 @@ static ChainstateManager::Options&& Flatten(ChainstateManager::Options&& opts)
return std::move(opts);
}
-ChainstateManager::ChainstateManager(Options options) : m_options{Flatten(std::move(options))} {}
+ChainstateManager::ChainstateManager(Options options, node::BlockManager::Options blockman_options)
+ : m_options{Flatten(std::move(options))},
+ m_blockman{std::move(blockman_options)} {}
ChainstateManager::~ChainstateManager()
{
diff --git a/src/validation.h b/src/validation.h
index b0cef0d37b..8fac2f6091 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -955,7 +955,7 @@ private:
public:
using Options = kernel::ChainstateManagerOpts;
- explicit ChainstateManager(Options options);
+ explicit ChainstateManager(Options options, node::BlockManager::Options blockman_options);
const CChainParams& GetParams() const { return m_options.chainparams; }
const Consensus::Params& GetConsensus() const { return m_options.chainparams.GetConsensus(); }