Changeset View
Changeset View
Standalone View
Standalone View
src/chain.h
Show First 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | struct BlockHasher { | ||||
// this used to call `GetCheapHash()` in uint256, which was later moved; the | // this used to call `GetCheapHash()` in uint256, which was later moved; the | ||||
// cheap hash function simply calls ReadLE64() however, so the end result is | // cheap hash function simply calls ReadLE64() however, so the end result is | ||||
// identical | // identical | ||||
size_t operator()(const BlockHash &hash) const { | size_t operator()(const BlockHash &hash) const { | ||||
return ReadLE64(hash.begin()); | return ReadLE64(hash.begin()); | ||||
} | } | ||||
}; | }; | ||||
typedef std::unordered_map<BlockHash, CBlockIndex *, BlockHasher> BlockMap; | |||||
extern BlockMap &mapBlockIndex; | |||||
extern CCriticalSection cs_main; | extern CCriticalSection cs_main; | ||||
typedef std::unordered_map<BlockHash, CBlockIndex *, BlockHasher> BlockMap; | |||||
extern BlockMap &mapBlockIndex GUARDED_BY(cs_main); | |||||
inline CBlockIndex *LookupBlockIndex(const BlockHash &hash) { | inline CBlockIndex *LookupBlockIndex(const BlockHash &hash) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
BlockMap::const_iterator it = mapBlockIndex.find(hash); | BlockMap::const_iterator it = mapBlockIndex.find(hash); | ||||
return it == mapBlockIndex.end() ? nullptr : it->second; | return it == mapBlockIndex.end() ? nullptr : it->second; | ||||
} | } | ||||
arith_uint256 GetBlockProof(const CBlockIndex &block); | arith_uint256 GetBlockProof(const CBlockIndex &block); | ||||
▲ Show 20 Lines • Show All 167 Lines • Show Last 20 Lines |