Dash Core  0.12.2.1
P2P Digital Currency
CBlockIndex Class Reference

#include <chain.h>

+ Inheritance diagram for CBlockIndex:

Public Types

enum  { nMedianTimeSpan =11 }
 

Public Member Functions

void SetNull ()
 
 CBlockIndex ()
 
 CBlockIndex (const CBlockHeader &block)
 
CDiskBlockPos GetBlockPos () const
 
CDiskBlockPos GetUndoPos () const
 
CBlockHeader GetBlockHeader () const
 
uint256 GetBlockHash () const
 
int64_t GetBlockTime () 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
 
unsigned int nStatus
 Verification status of this block. See enum BlockStatus. More...
 
int nVersion
 block header More...
 
uint256 hashMerkleRoot
 
unsigned int nTime
 
unsigned int nBits
 
unsigned int nNonce
 
uint32_t nSequenceId
 (memory only) Sequential id assigned to distinguish order in which blocks are received. More...
 

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.

Definition at line 100 of file chain.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
nMedianTimeSpan 

Definition at line 228 of file chain.h.

Constructor & Destructor Documentation

◆ CBlockIndex() [1/2]

CBlockIndex::CBlockIndex ( )
inline

Definition at line 171 of file chain.h.

◆ CBlockIndex() [2/2]

CBlockIndex::CBlockIndex ( const CBlockHeader block)
inline

Definition at line 176 of file chain.h.

Member Function Documentation

◆ BuildSkip()

void CBlockIndex::BuildSkip ( )

Build the skiplist pointer for this entry.

Definition at line 109 of file chain.cpp.

Referenced by LoadBlockIndexDB().

◆ GetAncestor() [1/2]

CBlockIndex * CBlockIndex::GetAncestor ( int  height)

◆ GetAncestor() [2/2]

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

Definition at line 104 of file chain.cpp.

◆ GetBlockHash()

◆ GetBlockHeader()

CBlockHeader CBlockIndex::GetBlockHeader ( ) const
inline

Definition at line 205 of file chain.h.

Referenced by getblockheader(), getblockheaders(), and rest_headers().

◆ GetBlockPos()

CDiskBlockPos CBlockIndex::GetBlockPos ( ) const
inline

Definition at line 187 of file chain.h.

Referenced by ConnectBlock(), and ReadBlockFromDisk().

◆ GetBlockTime()

◆ GetMedianTimePast()

◆ GetUndoPos()

CDiskBlockPos CBlockIndex::GetUndoPos ( ) const
inline

Definition at line 196 of file chain.h.

Referenced by ConnectBlock(), and DisconnectBlock().

◆ 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.

Definition at line 253 of file chain.h.

Referenced by ConnectBlock(), getblocktemplate(), getchaintips(), LoadBlockIndexDB(), ProcessMessage(), and submitblock().

◆ RaiseValidity()

bool CBlockIndex::RaiseValidity ( enum BlockStatus  nUpTo)
inline

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

Definition at line 263 of file chain.h.

Referenced by ConnectBlock(), and ReceivedBlockTransactions().

◆ SetNull()

void CBlockIndex::SetNull ( )
inline

Definition at line 149 of file chain.h.

Referenced by CBlockIndex().

◆ ToString()

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

Member Data Documentation

◆ hashMerkleRoot

◆ 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

Definition at line 134 of file chain.h.

Referenced by CheckBlockIndex(), FindMostWorkChain(), getchaintips(), Checkpoints::GuessVerificationProgress(), LoadBlockIndexDB(), ReceivedBlockTransactions(), SetNull(), and UpdateTip().

◆ nChainWork

◆ nDataPos

unsigned int CBlockIndex::nDataPos

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

Definition at line 119 of file chain.h.

Referenced by GetBlockPos(), CBlockTreeDB::LoadBlockIndexGuts(), PruneOneBlockFile(), ReceivedBlockTransactions(), CDiskBlockIndex::SerializationOp(), and SetNull().

◆ nFile

int CBlockIndex::nFile

◆ nHeight

int CBlockIndex::nHeight

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

Definition at line 113 of file chain.h.

Referenced by AcceptBlock(), CMasternodeSync::AcceptedBlockHeader(), ActivateBestChainStep(), AppInit2(), blockheaderToJSON(), BlockTipChanged(), blockToJSON(), CheckBlockIndex(), CheckForkWarningConditions(), CheckForkWarningConditionsOnNewFork(), CheckIndexAgainstCheckpoint(), CMasternodeBroadcast::CheckOutpoint(), CheckSequenceLocks(), ComputeBlockVersion(), ConnectBlock(), ConnectTip(), CChain::Contains(), ContextualCheckBlock(), ContextualCheckBlockHeader(), CreateNewBlock(), DarkGravityWave(), DisconnectBlock(), EvaluateSequenceLocks(), FindFilesToPrune(), CChain::FindFork(), FindMostWorkChain(), getblockchaininfo(), getblocktemplate(), getchaintips(), CMerkleTx::GetDepthInMainChain(), ClientModel::getHeaderTipHeight(), ClientModel::getHeaderTipTime(), CChain::GetLocator(), GetNetworkHashPS(), GetNextWorkRequired(), GetNextWorkRequiredBTC(), GetSpendHeight(), AbstractThresholdConditionChecker::GetStateFor(), gettxout(), importwallet(), IncrementExtraNonce(), InvalidateBlock(), InvalidChainFound(), CGovernanceObject::IsCollateralValid(), KimotoGravityWell(), listsinceblock(), LoadBlockIndexDB(), CBlockTreeDB::LoadBlockIndexGuts(), CWallet::MarkConflicted(), masternode(), CChain::Next(), CMasternodeSync::NotifyHeaderTip(), CompareBlocksByHeight::operator()(), ProcessMessage(), ReconsiderBlock(), CMasternodePayments::RequestLowDataPaymentBlocks(), CWallet::ScanForWalletTransactions(), SendMessages(), CDiskBlockIndex::SerializationOp(), CMerkleTx::SetMerkleBranch(), SetNull(), CChain::SetTip(), CInstantSend::SyncTransaction(), CPrivateSend::SyncTransaction(), TestBlockValidity(), ToString(), TxToJSON(), PeerLogicValidation::UpdatedBlockTip(), CMasternodeSync::UpdatedBlockTip(), CInstantSend::UpdatedBlockTip(), CPrivateSendClient::UpdatedBlockTip(), CMasternodePayments::UpdatedBlockTip(), CMasternodeMan::UpdatedBlockTip(), CGovernanceManager::UpdatedBlockTip(), CMasternode::UpdateLastPaid(), TransactionRecord::updateStatus(), and CVerifyDB::VerifyDB().

◆ nNonce

◆ nSequenceId

uint32_t CBlockIndex::nSequenceId

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

Definition at line 147 of file chain.h.

Referenced by CheckBlockIndex(), ReceivedBlockTransactions(), and SetNull().

◆ nStatus

◆ nTime

◆ nTx

unsigned int CBlockIndex::nTx

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

Definition at line 129 of file chain.h.

Referenced by AcceptBlock(), AppInit2(), CheckBlockIndex(), getblock(), LoadBlockIndexDB(), CBlockTreeDB::LoadBlockIndexGuts(), ReceivedBlockTransactions(), rest_block(), CDiskBlockIndex::SerializationOp(), and SetNull().

◆ nUndoPos

unsigned int CBlockIndex::nUndoPos

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

Definition at line 122 of file chain.h.

Referenced by ConnectBlock(), GetUndoPos(), CBlockTreeDB::LoadBlockIndexGuts(), PruneOneBlockFile(), ReceivedBlockTransactions(), CDiskBlockIndex::SerializationOp(), and SetNull().

◆ nVersion

◆ phashBlock

const uint256* CBlockIndex::phashBlock

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

Definition at line 104 of file chain.h.

Referenced by CheckForkWarningConditions(), CheckIndexAgainstCheckpoint(), ConnectBlock(), GetBlockHash(), getchaintips(), and SetNull().

◆ pprev

◆ pskip

CBlockIndex* CBlockIndex::pskip

pointer to the index of some further predecessor of this block

Definition at line 110 of file chain.h.

Referenced by CheckBlockIndex(), GetAncestor(), and SetNull().


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