6 #ifndef BITCOIN_CHAIN_H 7 #define BITCOIN_CHAIN_H 24 template <
typename Stream,
typename Operation>
25 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
225 return (int64_t)
nTime;
240 std::sort(pbegin, pend);
241 return pbegin[(pend - pbegin)/2];
246 return strprintf(
"CBlockIndex(pprev=%p, nHeight=%d, merkle=%s, hashBlock=%s)",
302 template <
typename Stream,
typename Operation>
345 std::string str =
"CDiskBlockIndex(";
347 str +=
strprintf(
"\n hashBlock=%s, hashPrev=%s)",
372 if (nHeight < 0 || nHeight >= (
int)
vChain.size())
385 return (*
this)[pindex->
nHeight] == pindex;
391 return (*
this)[pindex->
nHeight + 1];
411 #endif // BITCOIN_CHAIN_H arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
full block available in blk*.dat
void SetTip(CBlockIndex *pindex)
CDiskBlockPos(int nFileIn, unsigned int nPosIn)
bool RaiseValidity(enum BlockStatus nUpTo)
CBlockIndex * pskip
pointer to the index of some further predecessor of this block
descends from failed block
bool IsValid(enum BlockStatus nUpTo=BLOCK_VALID_TRANSACTIONS) const
Check whether this block index entry is valid up to the passed validity level.
CBlockHeader GetBlockHeader() const
unsigned int nUndoPos
Byte offset within rev?????.dat where this block's undo data is stored.
CDiskBlockPos GetBlockPos() const
CBlockIndex(const CBlockHeader &block)
std::string ToString() const
CBlockIndex * operator[](int nHeight) const
bool Contains(const CBlockIndex *pindex) const
std::vector< CBlockIndex * > vChain
const uint256 * phashBlock
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
CDiskBlockPos GetUndoPos() const
stage after last reached validness failed
CDiskBlockIndex(const CBlockIndex *pindex)
const CBlockIndex * FindFork(const CBlockIndex *pindex) const
Parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, timestamp not in future...
uint32_t nSequenceId
(memory only) Sequential id assigned to distinguish order in which blocks are received.
CBlockIndex * Genesis() const
int nFile
Which # file this block is stored in (blk?????.dat)
std::string ToString() const
uint256 GetBlockHash() const
std::string ToString() const
friend bool operator==(const CDiskBlockPos &a, const CDiskBlockPos &b)
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
undo data available in rev*.dat
friend bool operator==(const CChain &a, const CChain &b)
CBlockIndex * Next(const CBlockIndex *pindex) const
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
unsigned int nStatus
Verification status of this block. See enum BlockStatus.
friend bool operator!=(const CDiskBlockPos &a, const CDiskBlockPos &b)
uint256 GetBlockHash() const
Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
CBlockIndex * Tip() const
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
int64_t GetMedianTimePast() const
int64_t GetBlockTime() const
CBlockIndex * pprev
pointer to the index of the predecessor of this block
CBlockLocator GetLocator(const CBlockIndex *pindex=NULL) const
unsigned int nDataPos
Byte offset within blk?????.dat where this block's data is stored.
void BuildSkip()
Build the skiplist pointer for this entry.
int nHeight
height of the entry in the chain. The genesis block has height 0
std::string ToString() const