diff options
author | Carl Dong <contact@carldong.me> | 2020-08-25 16:53:30 -0400 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2021-01-28 14:15:26 -0500 |
commit | f11d11600ddb0ddff6538250ae2a35df6112c3db (patch) | |
tree | 2a4f6863b2044a6bd8292670bccf911c80e56f1e /src/validation.cpp | |
parent | e4b95eefbc700ebc915bec312f77477ce3e87a7e (diff) | |
download | bitcoin-f11d11600ddb0ddff6538250ae2a35df6112c3db.tar.xz |
validation: Move GetLastCheckpoint to BlockManager
[META] This commit should be followed up by removing the comments and
assertions meant only to show that the change is correct.
GetLastCheckPoint mainly acts on BlockManager.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index 7e3957d8d8..5303436290 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3401,15 +3401,15 @@ std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBloc return commitment; } -//! Returns last CBlockIndex* that is a checkpoint -static CBlockIndex* GetLastCheckpoint(const CCheckpointData& data) EXCLUSIVE_LOCKS_REQUIRED(cs_main) +CBlockIndex* BlockManager::GetLastCheckpoint(const CCheckpointData& data) { const MapCheckpoints& checkpoints = data.mapCheckpoints; for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints)) { const uint256& hash = i.second; - CBlockIndex* pindex = g_chainman.m_blockman.LookupBlockIndex(hash); + assert(std::addressof(g_chainman.m_blockman) == std::addressof(*this)); + CBlockIndex* pindex = LookupBlockIndex(hash); if (pindex) { return pindex; } @@ -3441,7 +3441,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio // Don't accept any forks from the main chain prior to last checkpoint. // GetLastCheckpoint finds the last checkpoint in MapCheckpoints that's in our // BlockIndex(). - CBlockIndex* pcheckpoint = GetLastCheckpoint(params.Checkpoints()); + CBlockIndex* pcheckpoint = g_chainman.m_blockman.GetLastCheckpoint(params.Checkpoints()); if (pcheckpoint && nHeight < pcheckpoint->nHeight) { LogPrintf("ERROR: %s: forked chain older than last checkpoint (height %d)\n", __func__, nHeight); return state.Invalid(BlockValidationResult::BLOCK_CHECKPOINT, "bad-fork-prior-to-checkpoint"); |