Skip to content

Commit fa0572d

Browse files
author
MarcoFalke
committed
Pass mempool reference to chainstate constructor
1 parent 862fde8 commit fa0572d

7 files changed

+55
-37
lines changed

src/init.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
15501550
const int64_t load_block_index_start_time = GetTimeMillis();
15511551
try {
15521552
LOCK(cs_main);
1553-
chainman.InitializeChainstate();
1553+
chainman.InitializeChainstate(*Assert(node.mempool));
15541554
chainman.m_total_coinstip_cache = nCoinCacheUsage;
15551555
chainman.m_total_coinsdb_cache = nCoinDBCache;
15561556

src/test/util/setup_common.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,11 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
141141

142142
pblocktree.reset(new CBlockTreeDB(1 << 20, true));
143143

144+
m_node.mempool = &::mempool;
145+
m_node.mempool->setSanityCheck(1.0);
146+
144147
m_node.chainman = &::g_chainman;
145-
m_node.chainman->InitializeChainstate();
148+
m_node.chainman->InitializeChainstate(*m_node.mempool);
146149
::ChainstateActive().InitCoinsDB(
147150
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
148151
assert(!::ChainstateActive().CanFlushToDisk());
@@ -164,8 +167,6 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
164167
}
165168
g_parallel_script_checks = true;
166169

167-
m_node.mempool = &::mempool;
168-
m_node.mempool->setSanityCheck(1.0);
169170
m_node.banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
170171
m_node.connman = MakeUnique<CConnman>(0x1337, 0x1337); // Deterministic randomness for tests.
171172
m_node.peer_logic = MakeUnique<PeerLogicValidation>(*m_node.connman, m_node.banman.get(), *m_node.scheduler, *m_node.chainman, *m_node.mempool);

src/test/validation_chainstate_tests.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ BOOST_FIXTURE_TEST_SUITE(validation_chainstate_tests, TestingSetup)
2020
BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
2121
{
2222
ChainstateManager manager;
23+
CTxMemPool mempool;
2324

2425
//! Create and add a Coin with DynamicMemoryUsage of 80 bytes to the given view.
2526
auto add_coin = [](CCoinsViewCache& coins_view) -> COutPoint {
@@ -34,7 +35,7 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
3435
return outp;
3536
};
3637

37-
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate());
38+
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(mempool));
3839
c1.InitCoinsDB(
3940
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
4041
WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23));

src/test/validation_chainstatemanager_tests.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, TestingSetup)
2323
BOOST_AUTO_TEST_CASE(chainstatemanager)
2424
{
2525
ChainstateManager manager;
26+
CTxMemPool mempool;
2627
std::vector<CChainState*> chainstates;
2728
const CChainParams& chainparams = Params();
2829

2930
// Create a legacy (IBD) chainstate.
3031
//
31-
CChainState& c1 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate());
32+
CChainState& c1 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(mempool));
3233
chainstates.push_back(&c1);
3334
c1.InitCoinsDB(
3435
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
@@ -54,7 +55,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
5455

5556
// Create a snapshot-based chainstate.
5657
//
57-
CChainState& c2 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(GetRandHash()));
58+
CChainState& c2 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(mempool, GetRandHash()));
5859
chainstates.push_back(&c2);
5960
c2.InitCoinsDB(
6061
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
@@ -104,6 +105,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
104105
BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
105106
{
106107
ChainstateManager manager;
108+
CTxMemPool mempool;
107109
size_t max_cache = 10000;
108110
manager.m_total_coinsdb_cache = max_cache;
109111
manager.m_total_coinstip_cache = max_cache;
@@ -112,7 +114,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
112114

113115
// Create a legacy (IBD) chainstate.
114116
//
115-
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate());
117+
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(mempool));
116118
chainstates.push_back(&c1);
117119
c1.InitCoinsDB(
118120
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
@@ -129,7 +131,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
129131

130132
// Create a snapshot-based chainstate.
131133
//
132-
CChainState& c2 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(GetRandHash()));
134+
CChainState& c2 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(mempool, GetRandHash()));
133135
chainstates.push_back(&c2);
134136
c2.InitCoinsDB(
135137
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
@@ -147,7 +149,6 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
147149
BOOST_CHECK_CLOSE(c1.m_coinsdb_cache_size_bytes, max_cache * 0.05, 1);
148150
BOOST_CHECK_CLOSE(c2.m_coinstip_cache_size_bytes, max_cache * 0.95, 1);
149151
BOOST_CHECK_CLOSE(c2.m_coinsdb_cache_size_bytes, max_cache * 0.95, 1);
150-
151152
}
152153

153154
BOOST_AUTO_TEST_SUITE_END()

src/test/validation_flush_tests.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, BasicTestingSetup)
1818
//!
1919
BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
2020
{
21+
CTxMemPool mempool;
2122
BlockManager blockman{};
22-
CChainState chainstate{blockman};
23+
CChainState chainstate{mempool, blockman};
2324
chainstate.InitCoinsDB(/*cache_size_bytes*/ 1 << 10, /*in_memory*/ true, /*should_wipe*/ false);
2425
WITH_LOCK(::cs_main, chainstate.InitCoinsCache(1 << 10));
2526
CTxMemPool tx_pool{};

src/validation.cpp

+30-21
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,10 @@ static bool IsCurrentForFeeEstimation() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
370370
* and instead just erase from the mempool as needed.
371371
*/
372372

373-
static void UpdateMempoolForReorg(DisconnectedBlockTransactions& disconnectpool, bool fAddToMempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs)
373+
static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransactions& disconnectpool, bool fAddToMempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, mempool.cs)
374374
{
375375
AssertLockHeld(cs_main);
376+
AssertLockHeld(mempool.cs);
376377
std::vector<uint256> vHashUpdate;
377378
// disconnectpool's insertion_order index sorts the entries from
378379
// oldest to newest, but the oldest entry will be the last tx from the
@@ -1254,8 +1255,9 @@ void CoinsViews::InitCache()
12541255
m_cacheview = MakeUnique<CCoinsViewCache>(&m_catcherview);
12551256
}
12561257

1257-
CChainState::CChainState(BlockManager& blockman, uint256 from_snapshot_blockhash)
1258+
CChainState::CChainState(CTxMemPool& mempool, BlockManager& blockman, uint256 from_snapshot_blockhash)
12581259
: m_blockman(blockman),
1260+
m_mempool(mempool),
12591261
m_from_snapshot_blockhash(from_snapshot_blockhash) {}
12601262

12611263
void CChainState::InitCoinsDB(
@@ -2280,7 +2282,7 @@ bool CChainState::FlushStateToDisk(
22802282
{
22812283
bool fFlushForPrune = false;
22822284
bool fDoFullFlush = false;
2283-
CoinsCacheSizeState cache_state = GetCoinsCacheSizeState(&::mempool);
2285+
CoinsCacheSizeState cache_state = GetCoinsCacheSizeState(&m_mempool);
22842286
LOCK(cs_LastBlockFile);
22852287
if (fPruneMode && (fCheckForPruning || nManualPruneHeight > 0) && !fReindex) {
22862288
if (nManualPruneHeight > 0) {
@@ -2426,7 +2428,7 @@ static void AppendWarning(bilingual_str& res, const bilingual_str& warn)
24262428
}
24272429

24282430
/** Check warning conditions and do some notifications on new chain tip set. */
2429-
void static UpdateTip(const CBlockIndex* pindexNew, const CChainParams& chainParams)
2431+
static void UpdateTip(CTxMemPool& mempool, const CBlockIndex* pindexNew, const CChainParams& chainParams)
24302432
EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
24312433
{
24322434
// New best block
@@ -2472,7 +2474,6 @@ void static UpdateTip(const CBlockIndex* pindexNew, const CChainParams& chainPar
24722474
FormatISO8601DateTime(pindexNew->GetBlockTime()),
24732475
GuessVerificationProgress(chainParams.TxData(), pindexNew), ::ChainstateActive().CoinsTip().DynamicMemoryUsage() * (1.0 / (1<<20)), ::ChainstateActive().CoinsTip().GetCacheSize(),
24742476
!warning_messages.empty() ? strprintf(" warning='%s'", warning_messages.original) : "");
2475-
24762477
}
24772478

24782479
/** Disconnect m_chain's tip.
@@ -2485,8 +2486,11 @@ void static UpdateTip(const CBlockIndex* pindexNew, const CChainParams& chainPar
24852486
* disconnectpool (note that the caller is responsible for mempool consistency
24862487
* in any case).
24872488
*/
2488-
bool CChainState::DisconnectTip(BlockValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions *disconnectpool)
2489+
bool CChainState::DisconnectTip(BlockValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions* disconnectpool)
24892490
{
2491+
AssertLockHeld(cs_main);
2492+
AssertLockHeld(m_mempool.cs);
2493+
24902494
CBlockIndex *pindexDelete = m_chain.Tip();
24912495
assert(pindexDelete);
24922496
// Read block from disk.
@@ -2517,14 +2521,14 @@ bool CChainState::DisconnectTip(BlockValidationState& state, const CChainParams&
25172521
while (disconnectpool->DynamicMemoryUsage() > MAX_DISCONNECTED_TX_POOL_SIZE * 1000) {
25182522
// Drop the earliest entry, and remove its children from the mempool.
25192523
auto it = disconnectpool->queuedTx.get<insertion_order>().begin();
2520-
mempool.removeRecursive(**it, MemPoolRemovalReason::REORG);
2524+
m_mempool.removeRecursive(**it, MemPoolRemovalReason::REORG);
25212525
disconnectpool->removeEntry(it);
25222526
}
25232527
}
25242528

25252529
m_chain.SetTip(pindexDelete->pprev);
25262530

2527-
UpdateTip(pindexDelete->pprev, chainparams);
2531+
UpdateTip(m_mempool, pindexDelete->pprev, chainparams);
25282532
// Let wallets know transactions went from 1-confirmed to
25292533
// 0-confirmed or conflicted:
25302534
GetMainSignals().BlockDisconnected(pblock, pindexDelete);
@@ -2585,6 +2589,9 @@ class ConnectTrace {
25852589
*/
25862590
bool CChainState::ConnectTip(BlockValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions &disconnectpool)
25872591
{
2592+
AssertLockHeld(cs_main);
2593+
AssertLockHeld(m_mempool.cs);
2594+
25882595
assert(pindexNew->pprev == m_chain.Tip());
25892596
// Read block from disk.
25902597
int64_t nTime1 = GetTimeMicros();
@@ -2625,11 +2632,11 @@ bool CChainState::ConnectTip(BlockValidationState& state, const CChainParams& ch
26252632
int64_t nTime5 = GetTimeMicros(); nTimeChainState += nTime5 - nTime4;
26262633
LogPrint(BCLog::BENCH, " - Writing chainstate: %.2fms [%.2fs (%.2fms/blk)]\n", (nTime5 - nTime4) * MILLI, nTimeChainState * MICRO, nTimeChainState * MILLI / nBlocksTotal);
26272634
// Remove conflicting transactions from the mempool.;
2628-
mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight);
2635+
m_mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight);
26292636
disconnectpool.removeForBlock(blockConnecting.vtx);
26302637
// Update m_chain & related variables.
26312638
m_chain.SetTip(pindexNew);
2632-
UpdateTip(pindexNew, chainparams);
2639+
UpdateTip(m_mempool, pindexNew, chainparams);
26332640

26342641
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
26352642
LogPrint(BCLog::BENCH, " - Connect postprocess: %.2fms [%.2fs (%.2fms/blk)]\n", (nTime6 - nTime5) * MILLI, nTimePostConnect * MICRO, nTimePostConnect * MILLI / nBlocksTotal);
@@ -2719,6 +2726,7 @@ void CChainState::PruneBlockIndexCandidates() {
27192726
bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace)
27202727
{
27212728
AssertLockHeld(cs_main);
2729+
AssertLockHeld(m_mempool.cs);
27222730

27232731
const CBlockIndex *pindexOldTip = m_chain.Tip();
27242732
const CBlockIndex *pindexFork = m_chain.FindFork(pindexMostWork);
@@ -2730,7 +2738,7 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChai
27302738
if (!DisconnectTip(state, chainparams, &disconnectpool)) {
27312739
// This is likely a fatal error, but keep the mempool consistent,
27322740
// just in case. Only remove from the mempool in this case.
2733-
UpdateMempoolForReorg(disconnectpool, false);
2741+
UpdateMempoolForReorg(m_mempool, disconnectpool, false);
27342742

27352743
// If we're unable to disconnect a block during normal operation,
27362744
// then that is a failure of our local system -- we should abort
@@ -2774,7 +2782,7 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChai
27742782
// A system error occurred (disk space, database error, ...).
27752783
// Make the mempool consistent with the current tip, just in case
27762784
// any observers try to use it before shutdown.
2777-
UpdateMempoolForReorg(disconnectpool, false);
2785+
UpdateMempoolForReorg(m_mempool, disconnectpool, false);
27782786
return false;
27792787
}
27802788
} else {
@@ -2791,9 +2799,9 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, const CChai
27912799
if (fBlocksDisconnected) {
27922800
// If any blocks were disconnected, disconnectpool may be non empty. Add
27932801
// any disconnected transactions back to the mempool.
2794-
UpdateMempoolForReorg(disconnectpool, true);
2802+
UpdateMempoolForReorg(m_mempool, disconnectpool, true);
27952803
}
2796-
mempool.check(&CoinsTip());
2804+
m_mempool.check(&CoinsTip());
27972805

27982806
// Callbacks/notifications for a new best chain.
27992807
if (fInvalidFound)
@@ -2867,7 +2875,8 @@ bool CChainState::ActivateBestChain(BlockValidationState &state, const CChainPar
28672875
LimitValidationInterfaceQueue();
28682876

28692877
{
2870-
LOCK2(cs_main, ::mempool.cs); // Lock transaction pool for at least as long as it takes for connectTrace to be consumed
2878+
LOCK(cs_main);
2879+
LOCK(m_mempool.cs); // Lock transaction pool for at least as long as it takes for connectTrace to be consumed
28712880
CBlockIndex* starting_tip = m_chain.Tip();
28722881
bool blocks_connected = false;
28732882
do {
@@ -3020,7 +3029,7 @@ bool CChainState::InvalidateBlock(BlockValidationState& state, const CChainParam
30203029
LimitValidationInterfaceQueue();
30213030

30223031
LOCK(cs_main);
3023-
LOCK(::mempool.cs); // Lock for as long as disconnectpool is in scope to make sure UpdateMempoolForReorg is called after DisconnectTip without unlocking in between
3032+
LOCK(m_mempool.cs); // Lock for as long as disconnectpool is in scope to make sure UpdateMempoolForReorg is called after DisconnectTip without unlocking in between
30243033
if (!m_chain.Contains(pindex)) break;
30253034
pindex_was_in_chain = true;
30263035
CBlockIndex *invalid_walk_tip = m_chain.Tip();
@@ -3034,7 +3043,7 @@ bool CChainState::InvalidateBlock(BlockValidationState& state, const CChainParam
30343043
// transactions back to the mempool if disconnecting was successful,
30353044
// and we're not doing a very deep invalidation (in which case
30363045
// keeping the mempool up to date is probably futile anyway).
3037-
UpdateMempoolForReorg(disconnectpool, /* fAddToMempool = */ (++disconnected <= 10) && ret);
3046+
UpdateMempoolForReorg(m_mempool, disconnectpool, /* fAddToMempool = */ (++disconnected <= 10) && ret);
30383047
if (!ret) return false;
30393048
assert(invalid_walk_tip->pprev == m_chain.Tip());
30403049

@@ -4517,7 +4526,8 @@ bool CChainState::RewindBlockIndex(const CChainParams& params)
45174526
// Loop until the tip is below nHeight, or we reach a pruned block.
45184527
while (!ShutdownRequested()) {
45194528
{
4520-
LOCK2(cs_main, ::mempool.cs);
4529+
LOCK(cs_main);
4530+
LOCK(m_mempool.cs);
45214531
// Make sure nothing changed from under us (this won't happen because RewindBlockIndex runs before importing/network are active)
45224532
assert(tip == m_chain.Tip());
45234533
if (tip == nullptr || tip->nHeight < nHeight) break;
@@ -5246,7 +5256,7 @@ std::vector<CChainState*> ChainstateManager::GetAll()
52465256
return out;
52475257
}
52485258

5249-
CChainState& ChainstateManager::InitializeChainstate(const uint256& snapshot_blockhash)
5259+
CChainState& ChainstateManager::InitializeChainstate(CTxMemPool& mempool, const uint256& snapshot_blockhash)
52505260
{
52515261
bool is_snapshot = !snapshot_blockhash.IsNull();
52525262
std::unique_ptr<CChainState>& to_modify =
@@ -5255,8 +5265,7 @@ CChainState& ChainstateManager::InitializeChainstate(const uint256& snapshot_blo
52555265
if (to_modify) {
52565266
throw std::logic_error("should not be overwriting a chainstate");
52575267
}
5258-
5259-
to_modify.reset(new CChainState(m_blockman, snapshot_blockhash));
5268+
to_modify.reset(new CChainState(mempool, m_blockman, snapshot_blockhash));
52605269

52615270
// Snapshot chainstates and initial IBD chaintates always become active.
52625271
if (is_snapshot || (!is_snapshot && !m_active_chainstate)) {

src/validation.h

+10-5
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,14 @@ class CChainState {
511511
//! easily as opposed to referencing a global.
512512
BlockManager& m_blockman;
513513

514+
//! mempool that is kept in sync with the chain
515+
CTxMemPool& m_mempool;
516+
514517
//! Manages the UTXO set, which is a reflection of the contents of `m_chain`.
515518
std::unique_ptr<CoinsViews> m_coins_views;
516519

517520
public:
518-
explicit CChainState(BlockManager& blockman, uint256 from_snapshot_blockhash = uint256());
521+
explicit CChainState(CTxMemPool& mempool, BlockManager& blockman, uint256 from_snapshot_blockhash = uint256());
519522

520523
/**
521524
* Initialize the CoinsViews UTXO set database management data structures. The in-memory
@@ -642,7 +645,7 @@ class CChainState {
642645
CCoinsViewCache& view, const CChainParams& chainparams, bool fJustCheck = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
643646

644647
// Apply the effects of a block disconnection on the UTXO set.
645-
bool DisconnectTip(BlockValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions* disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs);
648+
bool DisconnectTip(BlockValidationState& state, const CChainParams& chainparams, DisconnectedBlockTransactions* disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool.cs);
646649

647650
// Manual block validity manipulation:
648651
bool PreciousBlock(BlockValidationState& state, const CChainParams& params, CBlockIndex* pindex) LOCKS_EXCLUDED(cs_main);
@@ -685,8 +688,8 @@ class CChainState {
685688
std::string ToString() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
686689

687690
private:
688-
bool ActivateBestChainStep(BlockValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs);
689-
bool ConnectTip(BlockValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::mempool.cs);
691+
bool ActivateBestChainStep(BlockValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool.cs);
692+
bool ConnectTip(BlockValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool.cs);
690693

691694
void InvalidBlockFound(CBlockIndex *pindex, const BlockValidationState &state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
692695
CBlockIndex* FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
@@ -818,9 +821,11 @@ class ChainstateManager
818821
//! Instantiate a new chainstate and assign it based upon whether it is
819822
//! from a snapshot.
820823
//!
824+
//! @param[in] mempool The mempool to pass to the chainstate
825+
// constructor
821826
//! @param[in] snapshot_blockhash If given, signify that this chainstate
822827
//! is based on a snapshot.
823-
CChainState& InitializeChainstate(const uint256& snapshot_blockhash = uint256())
828+
CChainState& InitializeChainstate(CTxMemPool& mempool, const uint256& snapshot_blockhash = uint256())
824829
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
825830

826831
//! Get all chainstates currently being used.

0 commit comments

Comments
 (0)