99#include < rpc/blockchain.h> // for RPCNotifyBlockChange
1010#include < util/time.h> // for GetTime
1111#include < node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
12- #include < node/context.h> // for NodeContext
1312#include < node/ui_interface.h> // for InitError, uiInterface, and CClientUIInterface member access
1413#include < shutdown.h> // for ShutdownRequested
1514#include < validation.h> // for a lot of things
2625
2726std::optional<ChainstateLoadingError> LoadChainstate (bool fReset ,
2827 ChainstateManager& chainman,
29- NodeContext& node,
28+ CGovernanceManager& govman,
29+ CMasternodeMetaMan& mn_metaman,
30+ CMasternodeSync& mn_sync,
31+ CSporkManager& sporkman,
32+ std::unique_ptr<CActiveMasternodeManager>& mn_activeman,
33+ std::unique_ptr<CChainstateHelper>& chain_helper,
34+ std::unique_ptr<CCreditPoolManager>& cpoolman,
35+ std::unique_ptr<CDeterministicMNManager>& dmnman,
36+ std::unique_ptr<CEvoDB>& evodb,
37+ std::unique_ptr<CMNHFManager>& mnhf_manager,
38+ std::unique_ptr<llmq::CChainLocksHandler>& clhandler,
39+ std::unique_ptr<llmq::CInstantSendManager>& isman,
40+ std::unique_ptr<llmq::CQuorumSnapshotManager>& qsnapman,
41+ std::unique_ptr<LLMQContext>& llmq_ctx,
42+ CTxMemPool* mempool,
3043 bool fPruneMode ,
3144 bool is_addrindex_enabled,
3245 bool is_governance_enabled,
@@ -50,13 +63,13 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
5063 LOCK (cs_main);
5164
5265 int64_t nEvoDbCache{64 * 1024 * 1024 }; // TODO
53- node. evodb .reset ();
54- node. evodb = std::make_unique<CEvoDB>(nEvoDbCache, false , fReset || fReindexChainState );
66+ evodb.reset ();
67+ evodb = std::make_unique<CEvoDB>(nEvoDbCache, false , fReset || fReindexChainState );
5568
56- node. mnhf_manager .reset ();
57- node. mnhf_manager = std::make_unique<CMNHFManager>(*node. evodb );
69+ mnhf_manager.reset ();
70+ mnhf_manager = std::make_unique<CMNHFManager>(*evodb);
5871
59- chainman.InitializeChainstate (Assert (node. mempool . get ()) , *node. evodb , node. chain_helper , llmq::chainLocksHandler, llmq::quorumInstantSendManager );
72+ chainman.InitializeChainstate (Assert (mempool) , *evodb, chain_helper, clhandler, isman );
6073 chainman.m_total_coinstip_cache = nCoinCacheUsage;
6174 chainman.m_total_coinsdb_cache = nCoinDBCache;
6275
@@ -67,29 +80,29 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
6780 pblocktree.reset (new CBlockTreeDB (nBlockTreeDBCache, false , fReset ));
6881
6982 // Same logic as above with pblocktree
70- node. dmnman .reset ();
71- node. dmnman = std::make_unique<CDeterministicMNManager>(chainman.ActiveChainstate (), *node. evodb );
72- node. mempool ->ConnectManagers (node. dmnman .get ());
83+ dmnman.reset ();
84+ dmnman = std::make_unique<CDeterministicMNManager>(chainman.ActiveChainstate (), *evodb);
85+ mempool->ConnectManagers (dmnman.get ());
7386
74- node. cpoolman .reset ();
75- node. cpoolman = std::make_unique<CCreditPoolManager>(*node. evodb );
87+ cpoolman.reset ();
88+ cpoolman = std::make_unique<CCreditPoolManager>(*evodb);
7689
77- llmq::quorumSnapshotManager .reset ();
78- llmq::quorumSnapshotManager .reset (new llmq::CQuorumSnapshotManager (*node. evodb ));
90+ qsnapman .reset ();
91+ qsnapman .reset (new llmq::CQuorumSnapshotManager (*evodb));
7992
80- if (node. llmq_ctx ) {
81- node. llmq_ctx ->Interrupt ();
82- node. llmq_ctx ->Stop ();
93+ if (llmq_ctx) {
94+ llmq_ctx->Interrupt ();
95+ llmq_ctx->Stop ();
8396 }
84- node. llmq_ctx .reset ();
85- node. llmq_ctx = std::make_unique<LLMQContext>(chainman, *node. dmnman , *node. evodb , *node. mn_metaman , *node. mnhf_manager , *node. sporkman ,
86- *node. mempool , node. mn_activeman .get (), *node. mn_sync , /* unit_tests=*/ false , /* wipe=*/ fReset || fReindexChainState );
97+ llmq_ctx.reset ();
98+ llmq_ctx = std::make_unique<LLMQContext>(chainman, *dmnman, *evodb, mn_metaman, *mnhf_manager, sporkman,
99+ * mempool, mn_activeman.get (), mn_sync, /* unit_tests=*/ false , /* wipe=*/ fReset || fReindexChainState );
87100 // Enable CMNHFManager::{Process, Undo}Block
88- node. mnhf_manager ->ConnectManagers (node. chainman . get (), node. llmq_ctx ->qman .get ());
101+ mnhf_manager->ConnectManagers (& chainman, llmq_ctx->qman .get ());
89102
90- node. chain_helper .reset ();
91- node. chain_helper = std::make_unique<CChainstateHelper>(*node. cpoolman , *node. dmnman , *node. mnhf_manager , *node. govman , *(node. llmq_ctx ->quorum_block_processor ), *node. chainman ,
92- chainparams.GetConsensus (), *node. mn_sync , *node. sporkman , *(node. llmq_ctx ->clhandler ), *(node. llmq_ctx ->qman ));
103+ chain_helper.reset ();
104+ chain_helper = std::make_unique<CChainstateHelper>(*cpoolman, *dmnman, *mnhf_manager, govman, *(llmq_ctx->quorum_block_processor ), chainman,
105+ chainparams.GetConsensus (), mn_sync, sporkman, *(llmq_ctx->clhandler ), *(llmq_ctx->qman ));
93106
94107 if (fReset ) {
95108 pblocktree->WriteReindexing (true );
@@ -198,7 +211,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
198211 // TODO: CEvoDB instance should probably be a part of CChainState
199212 // (for multiple chainstates to actually work in parallel)
200213 // and not a global
201- if (&chainman.ActiveChainstate () == chainstate && !node. evodb ->CommitRootTransaction ()) {
214+ if (&chainman.ActiveChainstate () == chainstate && !evodb->CommitRootTransaction ()) {
202215 return ChainstateLoadingError::ERROR_COMMITING_EVO_DB;
203216 }
204217
@@ -211,10 +224,10 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
211224 }
212225 }
213226
214- if (!node. dmnman ->MigrateDBIfNeeded () || !node. dmnman ->MigrateDBIfNeeded2 ()) {
227+ if (!dmnman->MigrateDBIfNeeded () || !dmnman->MigrateDBIfNeeded2 ()) {
215228 return ChainstateLoadingError::ERROR_UPGRADING_EVO_DB;
216229 }
217- if (!node. mnhf_manager ->ForceSignalDBUpdate ()) {
230+ if (!mnhf_manager->ForceSignalDBUpdate ()) {
218231 return ChainstateLoadingError::ERROR_UPGRADING_SIGNALS_DB;
219232 }
220233 } catch (const std::exception& e) {
@@ -246,7 +259,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
246259
247260 if (!CVerifyDB ().VerifyDB (
248261 *chainstate, chainparams, chainstate->CoinsDB (),
249- *node. evodb ,
262+ *evodb,
250263 check_level,
251264 check_blocks)) {
252265 return ChainstateLoadingError::ERROR_CORRUPTED_BLOCK_DB;
@@ -267,7 +280,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
267280 // TODO: CEvoDB instance should probably be a part of CChainState
268281 // (for multiple chainstates to actually work in parallel)
269282 // and not a global
270- if (&chainman.ActiveChainstate () == chainstate && !node. evodb ->IsEmpty ()) {
283+ if (&chainman.ActiveChainstate () == chainstate && !evodb->IsEmpty ()) {
271284 // EvoDB processed some blocks earlier but we have no blocks anymore, something is wrong
272285 return ChainstateLoadingError::ERROR_EVO_DB_SANITY_FAILED;
273286 }
0 commit comments