diff options
-rw-r--r-- | src/index/base.cpp | 2 | ||||
-rw-r--r-- | src/net_processing.cpp | 4 | ||||
-rw-r--r-- | src/node/interfaces.cpp | 2 | ||||
-rw-r--r-- | src/validation.cpp | 5 | ||||
-rw-r--r-- | src/validation.h | 6 |
5 files changed, 10 insertions, 9 deletions
diff --git a/src/index/base.cpp b/src/index/base.cpp index 505c9c45b7..3d3dda95b1 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -62,7 +62,7 @@ bool BaseIndex::Init() if (locator.IsNull()) { m_best_block_index = nullptr; } else { - m_best_block_index = FindForkInGlobalIndex(::ChainActive(), locator); + m_best_block_index = g_chainman.m_blockman.FindForkInGlobalIndex(::ChainActive(), locator); } m_synced = m_best_block_index.load() == ::ChainActive().Tip(); return true; diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 6d96ccde63..fb013a0deb 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2968,7 +2968,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, LOCK(cs_main); // Find the last block the caller has in the main chain - const CBlockIndex* pindex = FindForkInGlobalIndex(::ChainActive(), locator); + const CBlockIndex* pindex = g_chainman.m_blockman.FindForkInGlobalIndex(::ChainActive(), locator); // Send the rest of the chain if (pindex) @@ -3088,7 +3088,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, else { // Find the last block the caller has in the main chain - pindex = FindForkInGlobalIndex(::ChainActive(), locator); + pindex = g_chainman.m_blockman.FindForkInGlobalIndex(::ChainActive(), locator); if (pindex) pindex = ::ChainActive().Next(pindex); } diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index e0bd07bc5a..b7efd68cfd 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -447,7 +447,7 @@ public: { LOCK(cs_main); const CChain& active = Assert(m_node.chainman)->ActiveChain(); - if (CBlockIndex* fork = FindForkInGlobalIndex(active, locator)) { + if (CBlockIndex* fork = g_chainman.m_blockman.FindForkInGlobalIndex(active, locator)) { return fork->nHeight; } return nullopt; diff --git a/src/validation.cpp b/src/validation.cpp index cabceca91b..69207fb529 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -175,14 +175,15 @@ CBlockIndex* BlockManager::LookupBlockIndex(const uint256& hash) return it == m_block_index.end() ? nullptr : it->second; } -CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator) +CBlockIndex* BlockManager::FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator) { AssertLockHeld(cs_main); + assert(std::addressof(g_chainman.m_blockman) == std::addressof(*this)); // Find the latest block common to locator and chain - we expect that // locator.vHave is sorted descending by height. for (const uint256& hash : locator.vHave) { - CBlockIndex* pindex = g_chainman.m_blockman.LookupBlockIndex(hash); + CBlockIndex* pindex = LookupBlockIndex(hash); if (pindex) { if (chain.Contains(pindex)) return pindex; diff --git a/src/validation.h b/src/validation.h index e829c0c1c5..d8b6a65652 100644 --- a/src/validation.h +++ b/src/validation.h @@ -311,9 +311,6 @@ public: bool VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, int nCheckLevel, int nCheckDepth); }; -/** Find the last common block between the parameter chain and a locator. */ -CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator) EXCLUSIVE_LOCKS_REQUIRED(cs_main); - enum DisconnectResult { DISCONNECT_OK, // All good. @@ -433,6 +430,9 @@ public: CBlockIndex* LookupBlockIndex(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main); + /** Find the last common block between the parameter chain and a locator. */ + CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator) EXCLUSIVE_LOCKS_REQUIRED(cs_main); + ~BlockManager() { Unload(); } |