diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -488,7 +488,6 @@ blockfilter.cpp blockindex.cpp chain.cpp - checkpoints.cpp config.cpp consensus/activation.cpp consensus/tx_verify.cpp diff --git a/src/Makefile.am b/src/Makefile.am --- a/src/Makefile.am +++ b/src/Makefile.am @@ -138,7 +138,6 @@ chainparamsbase.h \ chainparamsconstants.h \ chainparamsseeds.h \ - checkpoints.h \ checkqueue.h \ clientversion.h \ coins.h \ @@ -311,7 +310,6 @@ blockfilter.cpp \ blockindex.cpp \ chain.cpp \ - checkpoints.cpp \ config.cpp \ consensus/activation.cpp \ consensus/tx_verify.cpp \ diff --git a/src/checkpoints.h b/src/checkpoints.h deleted file mode 100644 --- a/src/checkpoints.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2009-2016 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 - -class CBlockIndex; -struct BlockHash; -struct CCheckpointData; - -/** - * Block-chain checkpoints are compiled-in sanity checks. - * They are updated every release or three. - */ -namespace Checkpoints { - -//! Returns true if block passes checkpoint checks -bool CheckBlock(const CCheckpointData &data, int nHeight, - const BlockHash &hash); - -//! Returns last CBlockIndex* that is a checkpoint -CBlockIndex *GetLastCheckpoint(const CCheckpointData &data); - -} // namespace Checkpoints - -#endif // BITCOIN_CHECKPOINTS_H diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp deleted file mode 100644 --- a/src/checkpoints.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2009-2016 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 - -#include -#include -#include - -#include - -namespace Checkpoints { - -bool CheckBlock(const CCheckpointData &data, int nHeight, - const BlockHash &hash) { - const MapCheckpoints &checkpoints = data.mapCheckpoints; - - MapCheckpoints::const_iterator i = checkpoints.find(nHeight); - if (i == checkpoints.end()) { - return true; - } - return hash == i->second; -} - -CBlockIndex *GetLastCheckpoint(const CCheckpointData &data) - EXCLUSIVE_LOCKS_REQUIRED(cs_main) { - const MapCheckpoints &checkpoints = data.mapCheckpoints; - - for (const MapCheckpoints::value_type &i : reverse_iterate(checkpoints)) { - const BlockHash &hash = i.second; - CBlockIndex *pindex = LookupBlockIndex(hash); - if (pindex) { - return pindex; - } - } - - return nullptr; -} - -} // namespace Checkpoints diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -4,7 +4,6 @@ #include -#include #include #include #include diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/src/test/checkpoints_tests.cpp b/src/test/checkpoints_tests.cpp --- a/src/test/checkpoints_tests.cpp +++ b/src/test/checkpoints_tests.cpp @@ -7,8 +7,6 @@ // Unit tests for block-chain checkpoints // -#include - #include #include #include diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -649,6 +650,13 @@ const Consensus::Params ¶ms, BlockValidationOptions validationOptions); +namespace Checkpoints { +bool CheckBlock(const CCheckpointData &data, int nHeight, + const BlockHash &hash); +CBlockIndex *GetLastCheckpoint(const CCheckpointData &data) + EXCLUSIVE_LOCKS_REQUIRED(cs_main); +} // namespace Checkpoints + /** * This is a variant of ContextualCheckTransaction which computes the contextual * check for a transaction based on the chain tip. diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -9,8 +9,6 @@ #include #include #include -#include -#include #include #include #include @@ -26,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -3499,6 +3498,33 @@ return true; } +namespace Checkpoints { +bool CheckBlock(const CCheckpointData &data, int nHeight, + const BlockHash &hash) { + const MapCheckpoints &checkpoints = data.mapCheckpoints; + + MapCheckpoints::const_iterator i = checkpoints.find(nHeight); + if (i == checkpoints.end()) { + return true; + } + return hash == i->second; +} + +CBlockIndex *GetLastCheckpoint(const CCheckpointData &data) { + const MapCheckpoints &checkpoints = data.mapCheckpoints; + + for (const MapCheckpoints::value_type &i : reverse_iterate(checkpoints)) { + const BlockHash &hash = i.second; + CBlockIndex *pindex = LookupBlockIndex(hash); + if (pindex) { + return pindex; + } + } + + return nullptr; +} +} // namespace Checkpoints + /** * Context-dependent validity checks. * By "context", we mean only the previous block headers, but not the UTXO diff --git a/test/lint/lint-circular-dependencies.sh b/test/lint/lint-circular-dependencies.sh --- a/test/lint/lint-circular-dependencies.sh +++ b/test/lint/lint-circular-dependencies.sh @@ -33,7 +33,6 @@ "script/scriptcache -> validation -> script/scriptcache" "seeder/bitcoin -> seeder/db -> seeder/bitcoin" "chainparams -> protocol -> config -> chainparams" - "checkpoints -> validation -> checkpoints" ) EXIT_CODE=0