Changeset View
Changeset View
Standalone View
Standalone View
src/chain.h
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | struct BlockHasher { | ||||
// 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()); | ||||
} | } | ||||
}; | }; | ||||
extern RecursiveMutex cs_main; | extern RecursiveMutex cs_main; | ||||
typedef std::unordered_map<BlockHash, CBlockIndex *, BlockHasher> BlockMap; | |||||
extern BlockMap &mapBlockIndex GUARDED_BY(cs_main); | |||||
inline CBlockIndex *LookupBlockIndex(const BlockHash &hash) | |||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | |||||
AssertLockHeld(cs_main); | |||||
BlockMap::const_iterator it = mapBlockIndex.find(hash); | |||||
return it == mapBlockIndex.end() ? nullptr : it->second; | |||||
} | |||||
arith_uint256 GetBlockProof(const CBlockIndex &block); | arith_uint256 GetBlockProof(const CBlockIndex &block); | ||||
/** | /** | ||||
* Return the time it would take to redo the work difference between from and | * Return the time it would take to redo the work difference between from and | ||||
* to, assuming the current hashrate corresponds to the difficulty at tip, in | * to, assuming the current hashrate corresponds to the difficulty at tip, in | ||||
* seconds. | * seconds. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 162 Lines • Show Last 20 Lines |