Resolve the checkpoints <-> validation CD.
This commit resolves the checkpoints -> validation -> checkpoints cirular dependency by moving `CheckPoints::GetLastCheckpoint(const CCheckpointData& data)` from `checkpoints.cpp` to `validation.cpp`.
This commit is contained in:
parent
7b13c64645
commit
418d3230f8
9 changed files with 18 additions and 68 deletions
|
@ -113,7 +113,6 @@ BITCOIN_CORE_H = \
|
|||
chainparams.h \
|
||||
chainparamsbase.h \
|
||||
chainparamsseeds.h \
|
||||
checkpoints.h \
|
||||
checkqueue.h \
|
||||
clientversion.h \
|
||||
coins.h \
|
||||
|
@ -247,7 +246,6 @@ libbitcoin_server_a_SOURCES = \
|
|||
blockencodings.cpp \
|
||||
blockfilter.cpp \
|
||||
chain.cpp \
|
||||
checkpoints.cpp \
|
||||
consensus/tx_verify.cpp \
|
||||
flatfile.cpp \
|
||||
httprpc.cpp \
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
// Copyright (c) 2009-2018 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <checkpoints.h>
|
||||
|
||||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
#include <reverse_iterator.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
namespace Checkpoints {
|
||||
|
||||
CBlockIndex* 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 = LookupBlockIndex(hash);
|
||||
if (pindex) {
|
||||
return pindex;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace Checkpoints
|
|
@ -1,27 +0,0 @@
|
|||
// Copyright (c) 2009-2018 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_CHECKPOINTS_H
|
||||
#define BITCOIN_CHECKPOINTS_H
|
||||
|
||||
#include <uint256.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
class CBlockIndex;
|
||||
struct CCheckpointData;
|
||||
|
||||
/**
|
||||
* Block-chain checkpoints are compiled-in sanity checks.
|
||||
* They are updated every release or three.
|
||||
*/
|
||||
namespace Checkpoints
|
||||
{
|
||||
|
||||
//! Returns last CBlockIndex* that is a checkpoint
|
||||
CBlockIndex* GetLastCheckpoint(const CCheckpointData& data);
|
||||
|
||||
} //namespace Checkpoints
|
||||
|
||||
#endif // BITCOIN_CHECKPOINTS_H
|
|
@ -14,7 +14,6 @@
|
|||
#include <banman.h>
|
||||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
#include <checkpoints.h>
|
||||
#include <compat/sanity.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <fs.h>
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
#include <checkpoints.h>
|
||||
#include <clientversion.h>
|
||||
#include <interfaces/handler.h>
|
||||
#include <interfaces/node.h>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <base58.h>
|
||||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
#include <checkpoints.h>
|
||||
#include <coins.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <core_io.h>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <arith_uint256.h>
|
||||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
#include <checkpoints.h>
|
||||
#include <checkqueue.h>
|
||||
#include <consensus/consensus.h>
|
||||
#include <consensus/merkle.h>
|
||||
|
@ -35,6 +34,7 @@
|
|||
#include <txdb.h>
|
||||
#include <txmempool.h>
|
||||
#include <ui_interface.h>
|
||||
#include <uint256.h>
|
||||
#include <undo.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/strencodings.h>
|
||||
|
@ -3196,6 +3196,22 @@ std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBloc
|
|||
return commitment;
|
||||
}
|
||||
|
||||
//! Returns last CBlockIndex* that is a checkpoint
|
||||
static CBlockIndex* 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 = LookupBlockIndex(hash);
|
||||
if (pindex) {
|
||||
return pindex;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** Context-dependent validity checks.
|
||||
* By "context", we mean only the previous block headers, but not the UTXO
|
||||
* set; UTXO-related validity checks are done in ConnectBlock().
|
||||
|
@ -3220,7 +3236,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta
|
|||
// Don't accept any forks from the main chain prior to last checkpoint.
|
||||
// GetLastCheckpoint finds the last checkpoint in MapCheckpoints that's in our
|
||||
// MapBlockIndex.
|
||||
CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(params.Checkpoints());
|
||||
CBlockIndex* pcheckpoint = GetLastCheckpoint(params.Checkpoints());
|
||||
if (pcheckpoint && nHeight < pcheckpoint->nHeight)
|
||||
return state.DoS(100, error("%s: forked chain older than last checkpoint (height %d)", __func__, nHeight), REJECT_CHECKPOINT, "bad-fork-prior-to-checkpoint");
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
#include <checkpoints.h>
|
||||
#include <chain.h>
|
||||
#include <wallet/coincontrol.h>
|
||||
#include <consensus/consensus.h>
|
||||
|
|
|
@ -10,7 +10,6 @@ export LC_ALL=C
|
|||
|
||||
EXPECTED_CIRCULAR_DEPENDENCIES=(
|
||||
"chainparamsbase -> util/system -> chainparamsbase"
|
||||
"checkpoints -> validation -> checkpoints"
|
||||
"index/txindex -> validation -> index/txindex"
|
||||
"policy/fees -> txmempool -> policy/fees"
|
||||
"policy/policy -> validation -> policy/policy"
|
||||
|
|
Loading…
Reference in a new issue