mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-31 16:24:48 +02:00
validation: make CChainState::m_mempool optional
Since we now have multiple chainstate objects, only one of them is active at any given time. An active chainstate has a mempool, but there's no point to others having one. This change will simplify proposed assumeutxo semantics. See the discussion here: https://github.com/bitcoin/bitcoin/pull/15606#pullrequestreview-692965905 Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
This commit is contained in:
@@ -180,7 +180,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
||||
// instead of unit tests, but for now we need these here.
|
||||
RegisterAllCoreRPCCommands(tableRPC);
|
||||
|
||||
m_node.chainman->InitializeChainstate(*m_node.mempool);
|
||||
m_node.chainman->InitializeChainstate(m_node.mempool.get());
|
||||
m_node.chainman->ActiveChainstate().InitCoinsDB(
|
||||
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
|
||||
assert(!m_node.chainman->ActiveChainstate().CanFlushToDisk());
|
||||
|
||||
@@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
|
||||
return outp;
|
||||
};
|
||||
|
||||
CChainState& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(mempool));
|
||||
CChainState& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool));
|
||||
c1.InitCoinsDB(
|
||||
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
|
||||
WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23));
|
||||
|
||||
@@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
|
||||
|
||||
// Create a legacy (IBD) chainstate.
|
||||
//
|
||||
CChainState& c1 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(mempool));
|
||||
CChainState& c1 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(&mempool));
|
||||
chainstates.push_back(&c1);
|
||||
c1.InitCoinsDB(
|
||||
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
|
||||
@@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
|
||||
//
|
||||
const uint256 snapshot_blockhash = GetRandHash();
|
||||
CChainState& c2 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(
|
||||
mempool, snapshot_blockhash));
|
||||
&mempool, snapshot_blockhash));
|
||||
chainstates.push_back(&c2);
|
||||
|
||||
BOOST_CHECK_EQUAL(manager.SnapshotBlockhash().value(), snapshot_blockhash);
|
||||
@@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
|
||||
|
||||
// Create a legacy (IBD) chainstate.
|
||||
//
|
||||
CChainState& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(mempool));
|
||||
CChainState& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool));
|
||||
chainstates.push_back(&c1);
|
||||
c1.InitCoinsDB(
|
||||
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
|
||||
@@ -147,7 +147,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
|
||||
|
||||
// Create a snapshot-based chainstate.
|
||||
//
|
||||
CChainState& c2 = WITH_LOCK(cs_main, return manager.InitializeChainstate(mempool, GetRandHash()));
|
||||
CChainState& c2 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool, GetRandHash()));
|
||||
chainstates.push_back(&c2);
|
||||
c2.InitCoinsDB(
|
||||
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
|
||||
|
||||
@@ -20,7 +20,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
|
||||
{
|
||||
CTxMemPool mempool;
|
||||
BlockManager blockman{};
|
||||
CChainState chainstate{mempool, blockman};
|
||||
CChainState chainstate{&mempool, blockman};
|
||||
chainstate.InitCoinsDB(/*cache_size_bytes*/ 1 << 10, /*in_memory*/ true, /*should_wipe*/ false);
|
||||
WITH_LOCK(::cs_main, chainstate.InitCoinsCache(1 << 10));
|
||||
CTxMemPool tx_pool{};
|
||||
|
||||
Reference in New Issue
Block a user