mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
validation: Make LoadBlockIndex() a member of ChainstateManager
This commit is contained in:
parent
fa05fdf0f1
commit
fa84b1cd84
3 changed files with 11 additions and 11 deletions
|
|
@ -4154,9 +4154,9 @@ void BlockManager::Unload() {
|
|||
m_block_index.clear();
|
||||
}
|
||||
|
||||
bool static LoadBlockIndexDB(const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
bool static LoadBlockIndexDB(ChainstateManager& chainman, const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
{
|
||||
if (!g_chainman.m_blockman.LoadBlockIndex(
|
||||
if (!chainman.m_blockman.LoadBlockIndex(
|
||||
chainparams.GetConsensus(), *pblocktree,
|
||||
::ChainstateActive().setBlockIndexCandidates)) {
|
||||
return false;
|
||||
|
|
@ -4182,8 +4182,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) EXCLUSIVE_LOCKS_RE
|
|||
// Check presence of blk files
|
||||
LogPrintf("Checking all blk files are present...\n");
|
||||
std::set<int> setBlkDataFiles;
|
||||
for (const std::pair<const uint256, CBlockIndex*>& item : g_chainman.BlockIndex())
|
||||
{
|
||||
for (const std::pair<const uint256, CBlockIndex*>& item : chainman.BlockIndex()) {
|
||||
CBlockIndex* pindex = item.second;
|
||||
if (pindex->nStatus & BLOCK_HAVE_DATA) {
|
||||
setBlkDataFiles.insert(pindex->nFile);
|
||||
|
|
@ -4600,14 +4599,15 @@ void UnloadBlockIndex()
|
|||
fHavePruned = false;
|
||||
}
|
||||
|
||||
bool LoadBlockIndex(const CChainParams& chainparams)
|
||||
bool ChainstateManager::LoadBlockIndex(const CChainParams& chainparams)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
// Load block index from databases
|
||||
bool needs_init = fReindex;
|
||||
if (!fReindex) {
|
||||
bool ret = LoadBlockIndexDB(chainparams);
|
||||
bool ret = LoadBlockIndexDB(*this, chainparams);
|
||||
if (!ret) return false;
|
||||
needs_init = g_chainman.m_blockman.m_block_index.empty();
|
||||
needs_init = m_blockman.m_block_index.empty();
|
||||
}
|
||||
|
||||
if (needs_init) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue