Bitcoin
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
CBlockIndex Class Reference

#include <chain.h>

Inheritance diagram for CBlockIndex:
CDiskBlockIndex

Public Member Functions

void SetNull ()
 
 CBlockIndex ()
 
 CBlockIndex (const CBlockHeader &block)
 
FlatFilePos GetBlockPos () const
 
FlatFilePos GetUndoPos () const
 
CBlockHeader GetBlockHeader () const
 
uint256 GetBlockHash () const
 
bool HaveTxsDownloaded () const
 
int64_t GetBlockTime () const
 
int64_t GetBlockTimeMax () const
 
int64_t GetMedianTimePast () const
 
std::string ToString () const
 
bool IsValid (enum BlockStatus nUpTo=BLOCK_VALID_TRANSACTIONS) const
 Check whether this block index entry is valid up to the passed validity level. More...
 
bool RaiseValidity (enum BlockStatus nUpTo)
 
void BuildSkip ()
 Build the skiplist pointer for this entry. More...
 
CBlockIndexGetAncestor (int height)
 Efficiently find an ancestor of this block. More...
 
const CBlockIndexGetAncestor (int height) const
 

Public Attributes

const uint256phashBlock
 pointer to the hash of the block, if any. Memory is owned by this CBlockIndex More...
 
CBlockIndexpprev
 pointer to the index of the predecessor of this block More...
 
CBlockIndexpskip
 pointer to the index of some further predecessor of this block More...
 
int nHeight
 height of the entry in the chain. The genesis block has height 0 More...
 
int nFile
 Which # file this block is stored in (blk?????.dat) More...
 
unsigned int nDataPos
 Byte offset within blk?????.dat where this block's data is stored. More...
 
unsigned int nUndoPos
 Byte offset within rev?????.dat where this block's undo data is stored. More...
 
arith_uint256 nChainWork
 (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block More...
 
unsigned int nTx
 
unsigned int nChainTx
 
uint32_t nStatus
 Verification status of this block. See enum BlockStatus. More...
 
int32_t nVersion
 block header More...
 
uint256 hashMerkleRoot
 
uint32_t nTime
 
uint32_t nBits
 
uint32_t nNonce
 
int32_t nSequenceId
 (memory only) Sequential id assigned to distinguish order in which blocks are received. More...
 
unsigned int nTimeMax
 (memory only) Maximum nTime in the chain up to and including this block. More...
 

Static Public Attributes

static constexpr int nMedianTimeSpan = 11
 

Detailed Description

The block chain is a tree shaped structure starting with the genesis block at the root, with each block potentially having multiple candidates to be the next block. A blockindex may have multiple pprev pointing to it, but at most one of them can be part of the currently active branch.

Constructor & Destructor Documentation

◆ CBlockIndex() [1/2]

CBlockIndex::CBlockIndex ( )
inline

◆ CBlockIndex() [2/2]

CBlockIndex::CBlockIndex ( const CBlockHeader block)
inlineexplicit

Member Function Documentation

◆ BuildSkip()

void CBlockIndex::BuildSkip ( )

Build the skiplist pointer for this entry.

◆ GetAncestor() [1/2]

CBlockIndex * CBlockIndex::GetAncestor ( int  height)

Efficiently find an ancestor of this block.

◆ GetAncestor() [2/2]

const CBlockIndex * CBlockIndex::GetAncestor ( int  height) const

◆ GetBlockHash()

uint256 CBlockIndex::GetBlockHash ( ) const
inline

◆ GetBlockHeader()

CBlockHeader CBlockIndex::GetBlockHeader ( ) const
inline

◆ GetBlockPos()

FlatFilePos CBlockIndex::GetBlockPos ( ) const
inline

◆ GetBlockTime()

int64_t CBlockIndex::GetBlockTime ( ) const
inline

◆ GetBlockTimeMax()

int64_t CBlockIndex::GetBlockTimeMax ( ) const
inline

◆ GetMedianTimePast()

int64_t CBlockIndex::GetMedianTimePast ( ) const
inline

◆ GetUndoPos()

FlatFilePos CBlockIndex::GetUndoPos ( ) const
inline

◆ HaveTxsDownloaded()

bool CBlockIndex::HaveTxsDownloaded ( ) const
inline

Check whether this block's and all previous blocks' transactions have been downloaded (and stored to disk) at some point.

Does not imply the transactions are consensus-valid (ConnectTip might fail) Does not imply the transactions are still stored on disk. (IsBlockPruned might return true)

◆ IsValid()

bool CBlockIndex::IsValid ( enum BlockStatus  nUpTo = BLOCK_VALID_TRANSACTIONS) const
inline

Check whether this block index entry is valid up to the passed validity level.

◆ RaiseValidity()

bool CBlockIndex::RaiseValidity ( enum BlockStatus  nUpTo)
inline

Raise the validity level of this block index entry. Returns true if the validity was changed.

◆ SetNull()

void CBlockIndex::SetNull ( )
inline

◆ ToString()

std::string CBlockIndex::ToString ( ) const
inline

Member Data Documentation

◆ hashMerkleRoot

uint256 CBlockIndex::hashMerkleRoot

◆ nBits

uint32_t CBlockIndex::nBits

◆ nChainTx

unsigned int CBlockIndex::nChainTx

(memory only) Number of transactions in the chain up to and including this block. This value will be non-zero only if and only if transactions for this block and all its parents are available. Change to 64-bit type when necessary; won't happen before 2030

◆ nChainWork

arith_uint256 CBlockIndex::nChainWork

(memory only) Total amount of work (expected number of hashes) in the chain up to and including this block

◆ nDataPos

unsigned int CBlockIndex::nDataPos

Byte offset within blk?????.dat where this block's data is stored.

◆ nFile

int CBlockIndex::nFile

Which # file this block is stored in (blk?????.dat)

◆ nHeight

int CBlockIndex::nHeight

height of the entry in the chain. The genesis block has height 0

◆ nMedianTimeSpan

constexpr int CBlockIndex::nMedianTimeSpan = 11
static

◆ nNonce

uint32_t CBlockIndex::nNonce

◆ nSequenceId

int32_t CBlockIndex::nSequenceId

(memory only) Sequential id assigned to distinguish order in which blocks are received.

◆ nStatus

uint32_t CBlockIndex::nStatus

Verification status of this block. See enum BlockStatus.

◆ nTime

uint32_t CBlockIndex::nTime

◆ nTimeMax

unsigned int CBlockIndex::nTimeMax

(memory only) Maximum nTime in the chain up to and including this block.

◆ nTx

unsigned int CBlockIndex::nTx

Number of transactions in this block. Note: in a potential headers-first mode, this number cannot be relied upon

◆ nUndoPos

unsigned int CBlockIndex::nUndoPos

Byte offset within rev?????.dat where this block's undo data is stored.

◆ nVersion

int32_t CBlockIndex::nVersion

block header

◆ phashBlock

const uint256* CBlockIndex::phashBlock

pointer to the hash of the block, if any. Memory is owned by this CBlockIndex

◆ pprev

CBlockIndex* CBlockIndex::pprev

pointer to the index of the predecessor of this block

◆ pskip

CBlockIndex* CBlockIndex::pskip

pointer to the index of some further predecessor of this block


The documentation for this class was generated from the following files: