diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -2045,7 +2045,7 @@ } if (fRequestShutdown) break; - if (!LoadBlockIndex(chainparams)) { + if (!LoadBlockIndex(config)) { strLoadError = _("Error loading block database"); break; } diff --git a/src/txdb.h b/src/txdb.h --- a/src/txdb.h +++ b/src/txdb.h @@ -18,6 +18,7 @@ class CBlockIndex; class CCoinsViewDBCursor; class uint256; +class Config; //! No need to periodic flush if at least this much space still available. static constexpr int MAX_BLOCK_COINSDB_USAGE = 10; @@ -125,6 +126,7 @@ bool WriteFlag(const std::string &name, bool fValue); bool ReadFlag(const std::string &name, bool &fValue); bool LoadBlockIndexGuts( + const Config &config, std::function insertBlockIndex); }; diff --git a/src/txdb.cpp b/src/txdb.cpp --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -6,7 +6,6 @@ #include "txdb.h" #include "chainparams.h" -#include "config.h" #include "hash.h" #include "init.h" #include "pow.h" @@ -275,8 +274,8 @@ } bool CBlockTreeDB::LoadBlockIndexGuts( + const Config &config, std::function insertBlockIndex) { - const Config &config = GetConfig(); std::unique_ptr pcursor(NewIterator()); diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -356,7 +356,7 @@ /** * Load the block tree and coins database from disk. */ -bool LoadBlockIndex(const CChainParams &chainparams); +bool LoadBlockIndex(const Config &config); /** * Update the chain tip based on database information. diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4336,8 +4336,8 @@ return pindexNew; } -static bool LoadBlockIndexDB(const CChainParams &chainparams) { - if (!pblocktree->LoadBlockIndexGuts(InsertBlockIndex)) { +static bool LoadBlockIndexDB(const Config &config) { + if (!pblocktree->LoadBlockIndexGuts(config, InsertBlockIndex)) { return false; } @@ -4836,9 +4836,9 @@ fHavePruned = false; } -bool LoadBlockIndex(const CChainParams &chainparams) { +bool LoadBlockIndex(const Config &config) { // Load block index from databases - if (!fReindex && !LoadBlockIndexDB(chainparams)) { + if (!fReindex && !LoadBlockIndexDB(config)) { return false; } return true;