aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am1
-rw-r--r--src/bitcoin-chainstate.cpp5
-rw-r--r--src/init.cpp5
-rw-r--r--src/kernel/chainstatemanager_opts.h22
-rw-r--r--src/test/util/setup_common.cpp5
-rw-r--r--src/test/validation_chainstate_tests.cpp7
-rw-r--r--src/validation.h6
7 files changed, 45 insertions, 6 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 357e562c69..d421e8f89d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -171,6 +171,7 @@ BITCOIN_CORE_H = \
interfaces/ipc.h \
interfaces/node.h \
interfaces/wallet.h \
+ kernel/chainstatemanager_opts.h \
key.h \
key_io.h \
logging.h \
diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp
index 812585ba1e..b667641964 100644
--- a/src/bitcoin-chainstate.cpp
+++ b/src/bitcoin-chainstate.cpp
@@ -70,7 +70,10 @@ int main(int argc, char* argv[])
// SETUP: Chainstate
- ChainstateManager chainman{chainparams};
+ const ChainstateManager::Options chainman_opts{
+ chainparams,
+ };
+ ChainstateManager chainman{chainman_opts};
auto rv = node::LoadChainstate(false,
std::ref(chainman),
diff --git a/src/init.cpp b/src/init.cpp
index 060541e975..ec94060e99 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1421,7 +1421,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
for (bool fLoaded = false; !fLoaded && !ShutdownRequested();) {
node.mempool = std::make_unique<CTxMemPool>(node.fee_estimator.get(), mempool_check_ratio);
- node.chainman = std::make_unique<ChainstateManager>(chainparams);
+ const ChainstateManager::Options chainman_opts{
+ chainparams,
+ };
+ node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
ChainstateManager& chainman = *node.chainman;
const bool fReset = fReindex;
diff --git a/src/kernel/chainstatemanager_opts.h b/src/kernel/chainstatemanager_opts.h
new file mode 100644
index 0000000000..f2646700a4
--- /dev/null
+++ b/src/kernel/chainstatemanager_opts.h
@@ -0,0 +1,22 @@
+// 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_CHAINSTATEMANAGER_OPTS_H
+#define BITCOIN_KERNEL_CHAINSTATEMANAGER_OPTS_H
+
+#include <cstdint>
+#include <functional>
+
+class CChainParams;
+
+/**
+ * An options struct for `ChainstateManager`, more ergonomically referred to as
+ * `ChainstateManager::Options` due to the using-declaration in
+ * `ChainstateManager`.
+ */
+struct ChainstateManagerOpts {
+ const CChainParams& chainparams;
+};
+
+#endif // BITCOIN_KERNEL_CHAINSTATEMANAGER_OPTS_H
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index ff78f87ec1..ba37a6113f 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -164,7 +164,10 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
m_cache_sizes = CalculateCacheSizes(m_args);
- m_node.chainman = std::make_unique<ChainstateManager>(chainparams);
+ const ChainstateManager::Options chainman_opts{
+ chainparams,
+ };
+ m_node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
m_node.chainman->m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(m_cache_sizes.block_tree_db, true);
// Start script-checking threads. Set g_parallel_script_checks to true so they are used.
diff --git a/src/test/validation_chainstate_tests.cpp b/src/test/validation_chainstate_tests.cpp
index e7c7584f1c..55c2228767 100644
--- a/src/test/validation_chainstate_tests.cpp
+++ b/src/test/validation_chainstate_tests.cpp
@@ -22,8 +22,11 @@ BOOST_FIXTURE_TEST_SUITE(validation_chainstate_tests, TestingSetup)
//!
BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
{
- const CChainParams& chainparams = Params();
- ChainstateManager manager(chainparams);
+ const ChainstateManager::Options chainman_opts{
+ Params(),
+ };
+ ChainstateManager manager{chainman_opts};
+
WITH_LOCK(::cs_main, manager.m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(1 << 20, true));
CTxMemPool mempool;
diff --git a/src/validation.h b/src/validation.h
index 04745a6e36..cae4ed4f14 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -14,6 +14,7 @@
#include <attributes.h>
#include <chain.h>
#include <chainparams.h>
+#include <kernel/chainstatemanager_opts.h>
#include <consensus/amount.h>
#include <deploymentstatus.h>
#include <fs.h>
@@ -853,7 +854,10 @@ private:
friend CChainState;
public:
- explicit ChainstateManager(const CChainParams& chainparams) : m_chainparams{chainparams} { }
+ using Options = ChainstateManagerOpts;
+
+ explicit ChainstateManager(const Options& opts)
+ : m_chainparams(opts.chainparams) {};
const CChainParams& GetParams() const { return m_chainparams; }
const Consensus::Params& GetConsensus() const { return m_chainparams.GetConsensus(); }