From fa27f03b4943540aa2eab283d4cf50ad4a1a01f8 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 1 Jul 2021 09:58:06 +0200 Subject: [PATCH] Move LoadBlockIndexDB to BlockManager --- src/validation.cpp | 10 +++++----- src/validation.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 26333d7026cc5..6c70fc686b9c8 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3764,10 +3764,10 @@ void BlockManager::Unload() { m_block_index.clear(); } -bool CChainState::LoadBlockIndexDB() +bool BlockManager::LoadBlockIndexDB(std::set& setBlockIndexCandidates) { - if (!m_blockman.LoadBlockIndex( - m_params.GetConsensus(), *pblocktree, + if (!LoadBlockIndex( + ::Params().GetConsensus(), *pblocktree, setBlockIndexCandidates)) { return false; } @@ -3792,7 +3792,7 @@ bool CChainState::LoadBlockIndexDB() // Check presence of blk files LogPrintf("Checking all blk files are present...\n"); std::set setBlkDataFiles; - for (const std::pair& item : m_blockman.m_block_index) { + for (const std::pair& item : m_block_index) { CBlockIndex* pindex = item.second; if (pindex->nStatus & BLOCK_HAVE_DATA) { setBlkDataFiles.insert(pindex->nFile); @@ -4114,7 +4114,7 @@ bool ChainstateManager::LoadBlockIndex() // Load block index from databases bool needs_init = fReindex; if (!fReindex) { - bool ret = ActiveChainstate().LoadBlockIndexDB(); + bool ret = m_blockman.LoadBlockIndexDB(ActiveChainstate().setBlockIndexCandidates); if (!ret) return false; needs_init = m_blockman.m_block_index.empty(); } diff --git a/src/validation.h b/src/validation.h index 9a2be3ad97260..3d2d51f262ace 100644 --- a/src/validation.h +++ b/src/validation.h @@ -446,6 +446,8 @@ class BlockManager */ std::multimap m_blocks_unlinked; + bool LoadBlockIndexDB(std::set& setBlockIndexCandidates) EXCLUSIVE_LOCKS_REQUIRED(::cs_main); + /** * Load the blocktree off disk and into memory. Populate certain metadata * per index entry (nStatus, nChainWork, nTimeMax, etc.) as well as peripheral @@ -798,8 +800,6 @@ class CChainState void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main); void InvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main); - bool LoadBlockIndexDB() EXCLUSIVE_LOCKS_REQUIRED(cs_main); - //! Indirection necessary to make lock annotations work with an optional mempool. RecursiveMutex* MempoolMutex() const LOCK_RETURNED(m_mempool->cs) {