@@ -28,13 +28,18 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
2828 ChainstateManager& chainman,
2929 NodeContext& node,
3030 bool fPruneMode ,
31+ bool is_addrindex_enabled,
3132 bool is_governance_enabled,
33+ bool is_spentindex_enabled,
34+ bool is_timeindex_enabled,
35+ bool is_txindex_enabled,
3236 const CChainParams& chainparams,
33- const ArgsManager& args,
3437 bool fReindexChainState ,
3538 int64_t nBlockTreeDBCache,
3639 int64_t nCoinDBCache,
37- int64_t nCoinCacheUsage)
40+ int64_t nCoinCacheUsage,
41+ unsigned int check_blocks,
42+ unsigned int check_level)
3843{
3944 auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED (::cs_main) {
4045 return fReset || fReindexChainState || chainstate->CoinsTip ().GetBestBlock ().IsNull ();
@@ -106,7 +111,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
106111
107112 // TODO: Remove this when pruning is fixed.
108113 // See https://github.com/dashpay/dash/pull/1817 and https://github.com/dashpay/dash/pull/1743
109- if (is_governance_enabled && !args. GetBoolArg ( " -txindex " , DEFAULT_TXINDEX) && chainparams.NetworkIDString () != CBaseChainParams::REGTEST) {
114+ if (is_governance_enabled && !is_txindex_enabled && chainparams.NetworkIDString () != CBaseChainParams::REGTEST) {
110115 return ChainstateLoadingError::ERROR_TXINDEX_DISABLED_WHEN_GOV_ENABLED;
111116 }
112117
@@ -124,17 +129,17 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
124129
125130 if (!fReset && !fReindexChainState ) {
126131 // Check for changed -addressindex state
127- if (!fAddressIndex && fAddressIndex != args. GetBoolArg ( " -addressindex " , DEFAULT_ADDRESSINDEX) ) {
132+ if (!fAddressIndex && fAddressIndex != is_addrindex_enabled ) {
128133 return ChainstateLoadingError::ERROR_ADDRIDX_NEEDS_REINDEX;
129134 }
130135
131136 // Check for changed -timestampindex state
132- if (!fTimestampIndex && fTimestampIndex != args. GetBoolArg ( " -timestampindex " , DEFAULT_TIMESTAMPINDEX) ) {
137+ if (!fTimestampIndex && fTimestampIndex != is_timeindex_enabled ) {
133138 return ChainstateLoadingError::ERROR_TIMEIDX_NEEDS_REINDEX;
134139 }
135140
136141 // Check for changed -spentindex state
137- if (!fSpentIndex && fSpentIndex != args. GetBoolArg ( " -spentindex " , DEFAULT_SPENTINDEX) ) {
142+ if (!fSpentIndex && fSpentIndex != is_spentindex_enabled ) {
138143 return ChainstateLoadingError::ERROR_SPENTIDX_NEEDS_REINDEX;
139144 }
140145 }
@@ -223,7 +228,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
223228 for (CChainState* chainstate : chainman.GetAll ()) {
224229 if (!is_coinsview_empty (chainstate)) {
225230 uiInterface.InitMessage (_ (" Verifying blocks…" ).translated );
226- if (chainman.m_blockman .m_have_pruned && args. GetArg ( " -checkblocks " , DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) {
231+ if (chainman.m_blockman .m_have_pruned && check_blocks > MIN_BLOCKS_TO_KEEP) {
227232 LogPrintf (" Prune: pruned datadir may not have more than %d blocks; only checking available blocks\n " ,
228233 MIN_BLOCKS_TO_KEEP);
229234 }
@@ -242,8 +247,8 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
242247 if (!CVerifyDB ().VerifyDB (
243248 *chainstate, chainparams, chainstate->CoinsDB (),
244249 *node.evodb ,
245- args. GetArg ( " -checklevel " , DEFAULT_CHECKLEVEL) ,
246- args. GetArg ( " -checkblocks " , DEFAULT_CHECKBLOCKS) )) {
250+ check_level ,
251+ check_blocks )) {
247252 return ChainstateLoadingError::ERROR_CORRUPTED_BLOCK_DB;
248253 }
249254
@@ -254,7 +259,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
254259 LogPrintf (" %s: bls_legacy_scheme=%d\n " , __func__, bls::bls_legacy_scheme.load ());
255260 }
256261
257- if (args. GetArg ( " -checklevel " , DEFAULT_CHECKLEVEL) >= 3 ) {
262+ if (check_level >= 3 ) {
258263 chainstate->ResetBlockFailureFlags (nullptr );
259264 }
260265
0 commit comments