Changeset View
Changeset View
Standalone View
Standalone View
src/chain.h
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_CHAIN_H | #ifndef BITCOIN_CHAIN_H | ||||
#define BITCOIN_CHAIN_H | #define BITCOIN_CHAIN_H | ||||
#include "arith_uint256.h" | #include "arith_uint256.h" | ||||
#include "consensus/params.h" | #include "consensus/params.h" | ||||
#include "pow.h" | #include "pow.h" | ||||
#include "primitives/block.h" | #include "primitives/block.h" | ||||
#include "tinyformat.h" | #include "tinyformat.h" | ||||
#include "uint256.h" | #include "uint256.h" | ||||
#include <unordered_map> | |||||
#include <vector> | #include <vector> | ||||
class CBlockFileInfo { | class CBlockFileInfo { | ||||
public: | public: | ||||
//!< number of blocks stored in file | //!< number of blocks stored in file | ||||
unsigned int nBlocks; | unsigned int nBlocks; | ||||
//!< number of used bytes of block file | //!< number of used bytes of block file | ||||
unsigned int nSize; | unsigned int nSize; | ||||
▲ Show 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | public: | ||||
//! Build the skiplist pointer for this entry. | //! Build the skiplist pointer for this entry. | ||||
void BuildSkip(); | void BuildSkip(); | ||||
//! Efficiently find an ancestor of this block. | //! Efficiently find an ancestor of this block. | ||||
CBlockIndex *GetAncestor(int height); | CBlockIndex *GetAncestor(int height); | ||||
const CBlockIndex *GetAncestor(int height) const; | 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<uint256, CBlockIndex *, BlockHasher> BlockMap; | |||||
extern BlockMap mapBlockIndex; | |||||
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. | ||||
*/ | */ | ||||
int64_t GetBlockProofEquivalentTime(const CBlockIndex &to, | int64_t GetBlockProofEquivalentTime(const CBlockIndex &to, | ||||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |