mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-28 09:51:31 +02:00
validation: add CChainParams to ChainstateManager
This commit is contained in:
parent
a8098f2cef
commit
69675ea4e7
@ -70,7 +70,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
|
|
||||||
// SETUP: Chainstate
|
// SETUP: Chainstate
|
||||||
ChainstateManager chainman;
|
ChainstateManager chainman{chainparams};
|
||||||
|
|
||||||
auto rv = node::LoadChainstate(false,
|
auto rv = node::LoadChainstate(false,
|
||||||
std::ref(chainman),
|
std::ref(chainman),
|
||||||
|
@ -1424,7 +1424,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
for (bool fLoaded = false; !fLoaded && !ShutdownRequested();) {
|
for (bool fLoaded = false; !fLoaded && !ShutdownRequested();) {
|
||||||
node.mempool = std::make_unique<CTxMemPool>(node.fee_estimator.get(), mempool_check_ratio);
|
node.mempool = std::make_unique<CTxMemPool>(node.fee_estimator.get(), mempool_check_ratio);
|
||||||
|
|
||||||
node.chainman = std::make_unique<ChainstateManager>();
|
node.chainman = std::make_unique<ChainstateManager>(chainparams);
|
||||||
ChainstateManager& chainman = *node.chainman;
|
ChainstateManager& chainman = *node.chainman;
|
||||||
|
|
||||||
const bool fReset = fReindex;
|
const bool fReset = fReindex;
|
||||||
|
@ -151,6 +151,8 @@ BasicTestingSetup::~BasicTestingSetup()
|
|||||||
ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
|
ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
|
||||||
: BasicTestingSetup(chainName, extra_args)
|
: BasicTestingSetup(chainName, extra_args)
|
||||||
{
|
{
|
||||||
|
const CChainParams& chainparams = Params();
|
||||||
|
|
||||||
// We have to run a scheduler thread to prevent ActivateBestChain
|
// We have to run a scheduler thread to prevent ActivateBestChain
|
||||||
// from blocking due to queue overrun.
|
// from blocking due to queue overrun.
|
||||||
m_node.scheduler = std::make_unique<CScheduler>();
|
m_node.scheduler = std::make_unique<CScheduler>();
|
||||||
@ -162,7 +164,7 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
|
|||||||
|
|
||||||
m_cache_sizes = CalculateCacheSizes(m_args);
|
m_cache_sizes = CalculateCacheSizes(m_args);
|
||||||
|
|
||||||
m_node.chainman = std::make_unique<ChainstateManager>();
|
m_node.chainman = std::make_unique<ChainstateManager>(chainparams);
|
||||||
m_node.chainman->m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(m_cache_sizes.block_tree_db, true);
|
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.
|
// Start script-checking threads. Set g_parallel_script_checks to true so they are used.
|
||||||
|
@ -22,7 +22,8 @@ BOOST_FIXTURE_TEST_SUITE(validation_chainstate_tests, TestingSetup)
|
|||||||
//!
|
//!
|
||||||
BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
|
BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
|
||||||
{
|
{
|
||||||
ChainstateManager manager;
|
const CChainParams& chainparams = Params();
|
||||||
|
ChainstateManager manager(chainparams);
|
||||||
WITH_LOCK(::cs_main, manager.m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(1 << 20, true));
|
WITH_LOCK(::cs_main, manager.m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(1 << 20, true));
|
||||||
CTxMemPool mempool;
|
CTxMemPool mempool;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <arith_uint256.h>
|
#include <arith_uint256.h>
|
||||||
#include <attributes.h>
|
#include <attributes.h>
|
||||||
#include <chain.h>
|
#include <chain.h>
|
||||||
|
#include <chainparams.h>
|
||||||
#include <consensus/amount.h>
|
#include <consensus/amount.h>
|
||||||
#include <fs.h>
|
#include <fs.h>
|
||||||
#include <node/blockstorage.h>
|
#include <node/blockstorage.h>
|
||||||
@ -51,6 +52,9 @@ struct AssumeutxoData;
|
|||||||
namespace node {
|
namespace node {
|
||||||
class SnapshotMetadata;
|
class SnapshotMetadata;
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
namespace Consensus {
|
||||||
|
struct Params;
|
||||||
|
} // namespace Consensus
|
||||||
|
|
||||||
/** Default for -minrelaytxfee, minimum relay fee for transactions */
|
/** Default for -minrelaytxfee, minimum relay fee for transactions */
|
||||||
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
|
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
|
||||||
@ -834,6 +838,8 @@ private:
|
|||||||
|
|
||||||
CBlockIndex* m_best_invalid GUARDED_BY(::cs_main){nullptr};
|
CBlockIndex* m_best_invalid GUARDED_BY(::cs_main){nullptr};
|
||||||
|
|
||||||
|
const CChainParams& m_chainparams;
|
||||||
|
|
||||||
//! Internal helper for ActivateSnapshot().
|
//! Internal helper for ActivateSnapshot().
|
||||||
[[nodiscard]] bool PopulateAndValidateSnapshot(
|
[[nodiscard]] bool PopulateAndValidateSnapshot(
|
||||||
CChainState& snapshot_chainstate,
|
CChainState& snapshot_chainstate,
|
||||||
@ -852,6 +858,11 @@ private:
|
|||||||
friend CChainState;
|
friend CChainState;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
explicit ChainstateManager(const CChainParams& chainparams) : m_chainparams{chainparams} { }
|
||||||
|
|
||||||
|
const CChainParams& GetParams() const { return m_chainparams; }
|
||||||
|
const Consensus::Params& GetConsensus() const { return m_chainparams.GetConsensus(); }
|
||||||
|
|
||||||
std::thread m_load_block;
|
std::thread m_load_block;
|
||||||
//! A single BlockManager instance is shared across each constructed
|
//! A single BlockManager instance is shared across each constructed
|
||||||
//! chainstate to avoid duplicating block metadata.
|
//! chainstate to avoid duplicating block metadata.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user