diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-11-23 18:07:00 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-12-15 17:45:48 +0100 |
commit | fa3d62cf7b3501a056b34c5458c14d2fe6a55bd7 (patch) | |
tree | 36896fec7741ad366d51a3f857ef801124c7f731 /src/validation.cpp | |
parent | c09b41dc665bcc7d6dcc464f1d279e8eca598c8d (diff) | |
download | bitcoin-fa3d62cf7b3501a056b34c5458c14d2fe6a55bd7.tar.xz |
Move FindForkInGlobalIndex from BlockManager to CChainState
The helper was moved in commit b026e318c39f59a06e29f1b25c7f577e01b25ccb,
which also mentioned that it could be moved to CChainState. So do that,
as the functionality is not block-storage related.
This also allows to drop one function argument.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 1aac71fb0f..c2d86d89c5 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -155,23 +155,24 @@ CBlockIndex* BlockManager::LookupBlockIndex(const uint256& hash) const return it == m_block_index.end() ? nullptr : it->second; } -CBlockIndex* BlockManager::FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator) +CBlockIndex* CChainState::FindForkInGlobalIndex(const CBlockLocator& locator) const { AssertLockHeld(cs_main); // 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 = LookupBlockIndex(hash); + CBlockIndex* pindex{m_blockman.LookupBlockIndex(hash)}; if (pindex) { - if (chain.Contains(pindex)) + if (m_chain.Contains(pindex)) { return pindex; - if (pindex->GetAncestor(chain.Height()) == chain.Tip()) { - return chain.Tip(); + } + if (pindex->GetAncestor(m_chain.Height()) == m_chain.Tip()) { + return m_chain.Tip(); } } } - return chain.Genesis(); + return m_chain.Genesis(); } bool CheckInputScripts(const CTransaction& tx, TxValidationState& state, |