diff --git a/src/chain.h b/src/chain.h --- a/src/chain.h +++ b/src/chain.h @@ -13,6 +13,7 @@ #include "tinyformat.h" #include "uint256.h" +#include #include class CBlockFileInfo { @@ -353,6 +354,16 @@ const CBlockIndex *GetAncestor(int height) const; }; +/** + * Maintain a map of CBlockIndex for all known headers. + */ +struct BlockHasher { + size_t operator()(const uint256 &hash) const { return hash.GetCheapHash(); } +}; + +typedef std::unordered_map BlockMap; +extern BlockMap mapBlockIndex; + arith_uint256 GetBlockProof(const CBlockIndex &block); /** diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -6,8 +6,6 @@ #include "chain.h" #include "chainparams.h" -#include "uint256.h" -#include "validation.h" #include @@ -22,8 +20,11 @@ boost::adaptors::reverse(checkpoints)) { const uint256 &hash = i.second; BlockMap::const_iterator t = mapBlockIndex.find(hash); - if (t != mapBlockIndex.end()) return t->second; + if (t != mapBlockIndex.end()) { + return t->second; + } } + return nullptr; } diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -20,6 +20,7 @@ #include "versionbits.h" #include +#include #include #include #include @@ -28,10 +29,7 @@ #include #include -#include - #include -#include class CBlockIndex; class CBlockTreeDB; @@ -167,15 +165,9 @@ static const bool DEFAULT_PEERBLOOMFILTERS = true; -struct BlockHasher { - size_t operator()(const uint256 &hash) const { return hash.GetCheapHash(); } -}; - extern CScript COINBASE_FLAGS; extern CCriticalSection cs_main; extern CTxMemPool mempool; -typedef std::unordered_map BlockMap; -extern BlockMap mapBlockIndex; extern uint64_t nLastBlockTx; extern uint64_t nLastBlockSize; extern const std::string strMessageMagic;