Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

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

#include <chain.h>

+ Inheritance diagram for CBlockIndex:
+ Collaboration diagram for CBlockIndex:

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 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)
 Raise the validity level of this block index entry. More...
 
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
 Number of transactions in this block. More...
 
unsigned int nChainTx
 (memory only) Number of transactions in the chain up to and including this block. More...
 
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.

Definition at line 170 of file chain.h.

Constructor & Destructor Documentation

◆ CBlockIndex() [1/2]

CBlockIndex::CBlockIndex ( )
inline

Definition at line 245 of file chain.h.

References SetNull().

◆ CBlockIndex() [2/2]

CBlockIndex::CBlockIndex ( const CBlockHeader block)
inlineexplicit

Member Function Documentation

◆ BuildSkip()

void CBlockIndex::BuildSkip ( )

Build the skiplist pointer for this entry.

Definition at line 115 of file chain.cpp.

References GetAncestor(), GetSkipHeight(), nHeight, pprev, and pskip.

Referenced by CChainState::LoadBlockIndex().

◆ GetAncestor() [1/2]

◆ GetAncestor() [2/2]

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

Definition at line 83 of file chain.cpp.

References GetSkipHeight(), nHeight, pprev, and pskip.

◆ GetBlockHash()

uint256 CBlockIndex::GetBlockHash ( ) const
inline

Definition at line 292 of file chain.h.

References phashBlock.

Referenced by llmq::CChainLocksHandler::AcceptedBlockHeader(), CChainState::ActivateBestChain(), llmq::CInstantSendManager::AddNonLockedTx(), llmq::CLLMQUtils::AddQuorumProbeConnections(), CWallet::AddToWalletIfInvolvingMe(), AlreadyHave(), CDeterministicMNList::ApplyDiff(), llmq::CChainLocksHandler::BlockConnected(), CWallet::BlockConnected(), llmq::CChainLocksHandler::BlockDisconnected(), blockheaderToJSON(), BlockNotifyCallback(), BlockTipChanged(), blockToJSON(), BOOST_FIXTURE_TEST_CASE(), CDeterministicMNManager::BuildNewListFromBlock(), llmq::CQuorumManager::BuildQuorumFromCommitment(), llmq::CLLMQUtils::CalcDeterministicWatchConnections(), CDiskBlockIndex::CDiskBlockIndex(), CChainState::CheckBlockIndex(), llmq::CInstantSendManager::CheckCanLock(), CDeterministicMNManager::CleanupCache(), CChainState::ConnectBlock(), CChainState::ConnectTip(), BlockAssembler::CreateNewBlock(), CChainState::DisconnectBlock(), CChainState::DisconnectTip(), llmq::CChainLocksHandler::DoInvalidateBlock(), dumpwallet(), llmq::CChainLocksHandler::EnforceBestChainLock(), llmq::CLLMQUtils::EnsureQuorumConnections(), llmq::CQuorumManager::EnsureQuorumConnections(), llmq::CLLMQUtils::GetAllQuorumMembers(), getbestblockhash(), getblockchaininfo(), getblockhash(), GetBlockHeader(), getblockstats(), getblocktemplate(), ClientModel::getLastBlockHash(), CDeterministicMNManager::GetListForBlock(), CChain::GetLocator(), llmq::CQuorumManager::GetQuorum(), GetTransaction(), gettxout(), llmq::CDKGSessionManager::GetVerifiedContribution(), llmq::CDKGSession::Init(), llmq::CChainLocksHandler::InternalHasChainLock(), llmq::CChainLocksHandler::InternalHasConflictingChainLock(), InvalidChainFound(), listsinceblock(), CChainState::LoadBlockIndex(), CBlockTreeDB::LoadBlockIndexGuts(), LoadChainTip(), CZMQPublishHashBlockNotifier::NotifyBlock(), CZMQPublishRawBlockNotifier::NotifyBlock(), CZMQPublishHashChainLockNotifier::NotifyChainLock(), CZMQPublishRawChainLockNotifier::NotifyChainLock(), CZMQPublishRawChainLockSigNotifier::NotifyChainLock(), llmq::CDKGSession::PreVerifyMessage(), CDeterministicMNManager::ProcessBlock(), ProcessGetBlockData(), ProcessHeadersMessage(), llmq::CInstantSendManager::ProcessInstantSendLock(), ProcessMessage(), llmq::CInstantSendManager::ProcessNewTransaction(), ReadBlockFromDisk(), CChainState::ReplayBlocks(), rest_getutxos(), CChainState::RollforwardBlock(), RPCNotifyBlockChange(), llmq::CQuorumManager::ScanQuorums(), llmq::CDKGSession::SendCommitment(), llmq::CDKGSession::SendComplaint(), llmq::CDKGSession::SendContributions(), llmq::CDKGSession::SendJustification(), PeerLogicValidation::SendMessages(), CMerkleTx::SetMerkleBranch(), ToString(), llmq::CChainLocksHandler::TrySignChainTip(), TxToJSON(), llmq::CQuorumBlockProcessor::UndoBlock(), PeerLogicValidation::UpdatedBlockTip(), CMasternodeSync::UpdatedBlockTip(), llmq::CDKGSessionHandler::UpdatedBlockTip(), UpdateTip(), llmq::CQuorumBlockProcessor::UpgradeDB(), CDeterministicMNManager::UpgradeDBIfNeeded(), CDeterministicMNManager::UpgradeDiff(), CVerifyDB::VerifyDB(), WriteUndoDataForBlock(), llmq::CDKGSessionManager::WriteVerifiedSkContribution(), and llmq::CDKGSessionManager::WriteVerifiedVvecContribution().

◆ GetBlockHeader()

◆ GetBlockPos()

CDiskBlockPos CBlockIndex::GetBlockPos ( ) const
inline

◆ GetBlockTime()

◆ GetBlockTimeMax()

int64_t CBlockIndex::GetBlockTimeMax ( ) const
inline

Definition at line 302 of file chain.h.

References nTimeMax.

Referenced by BOOST_FIXTURE_TEST_CASE(), and CWallet::RescanFromTime().

◆ GetMedianTimePast()

◆ GetUndoPos()

CDiskBlockPos CBlockIndex::GetUndoPos ( ) const
inline

◆ IsValid()

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

◆ 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 342 of file chain.h.

References BLOCK_FAILED_MASK, BLOCK_VALID_MASK, and nStatus.

Referenced by CChainState::AddToBlockIndex(), CChainState::ConnectBlock(), and CChainState::ReceivedBlockTransactions().

◆ SetNull()

void CBlockIndex::SetNull ( )
inline

◆ 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 204 of file chain.h.

Referenced by CChainState::CheckBlockIndex(), CChainState::FindMostWorkChain(), getchaintxstats(), GuessVerificationProgress(), CChainState::LoadBlockIndex(), CChainState::PreciousBlock(), CChainState::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 189 of file chain.h.

Referenced by GetBlockPos(), CBlockTreeDB::LoadBlockIndexGuts(), PruneOneBlockFile(), CChainState::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 183 of file chain.h.

Referenced by CChainState::AcceptBlock(), CMasternodeSync::AcceptedBlockHeader(), llmq::CChainLocksHandler::AcceptedBlockHeader(), CChainState::ActivateBestChain(), CChainState::ActivateBestChainStep(), CDeterministicMNList::ApplyDiff(), CPrivateSend::BlockConnected(), llmq::CInstantSendManager::BlockDisconnected(), blockheaderToJSON(), BlockTipChanged(), blockToJSON(), CWallet::BlockUntilSyncedToCurrentChain(), CDeterministicMNManager::BuildNewListFromBlock(), BuildSimplifiedMNListDiff(), BuildSkip(), CChainState::CheckBlockIndex(), llmq::CInstantSendManager::CheckCanLock(), CheckCbTx(), CheckForkWarningConditions(), CheckForkWarningConditionsOnNewFork(), llmq::CheckLLMQCommitment(), CheckProRegTx(), CheckProUpRegTx(), CheckSequenceLocks(), CheckSpecialTx(), CChainState::ConnectBlock(), CChainState::ConnectTip(), CChain::Contains(), ContextualCheckBlock(), ContextualCheckBlockHeader(), ContextualCheckTransaction(), BlockAssembler::CreateNewBlock(), CWallet::CreateWalletFromFile(), DarkGravityWave(), CChainState::DisconnectBlock(), llmq::CChainLocksHandler::EnforceBestChainLock(), llmq::CQuorumManager::EnsureQuorumConnections(), EvaluateSequenceLocks(), FindFilesToPrune(), FindFilesToPruneManual(), CChain::FindFork(), CChainState::FindMostWorkChain(), GetAncestor(), getblockchaininfo(), GetBlockScriptFlags(), getblockstats(), getblocktemplate(), getchaintips(), getchaintxstats(), llmq::CQuorumBlockProcessor::GetCommitmentsFromBlock(), CMerkleTx::GetDepthInMainChain(), ClientModel::getHeaderTipHeight(), ClientModel::getHeaderTipTime(), CDeterministicMNManager::GetListForBlock(), CChain::GetLocator(), llmq::CQuorumBlockProcessor::GetMinedCommitmentsUntilBlock(), GetNetworkHashPS(), GetNextWorkRequired(), GetNextWorkRequiredBTC(), GetSpendHeight(), AbstractThresholdConditionChecker::GetStateFor(), AbstractThresholdConditionChecker::GetStateSinceHeightFor(), AbstractThresholdConditionChecker::GetStateStatisticsFor(), gettxout(), llmq::CInstantSendManager::HandleFullyConfirmedBlock(), IncrementExtraNonce(), CActiveMasternodeManager::Init(), llmq::CDKGSession::Init(), llmq::CDKGSessionHandler::InitNewQuorum(), llmq::CChainLocksHandler::InternalHasChainLock(), llmq::CChainLocksHandler::InternalHasConflictingChainLock(), InvalidChainFound(), CGovernanceObject::IsCollateralValid(), IsCurrentForFeeEstimation(), CDeterministicMNManager::IsDIP3Enforced(), CPrivateSendBroadcastTx::IsExpired(), KimotoGravityWell(), LastCommonAncestor(), listsinceblock(), CChainState::LoadBlockIndex(), CBlockTreeDB::LoadBlockIndexGuts(), CWallet::MarkConflicted(), masternode_winners(), PeerLogicValidation::NewPoWValidBlock(), CChain::Next(), CWallet::NotifyChainLock(), CMasternodeSync::NotifyHeaderTip(), CompareBlocksByHeight::operator()(), llmq::CQuorumBlockProcessor::ProcessBlock(), CDeterministicMNManager::ProcessBlock(), ProcessGetBlockData(), ProcessHeadersMessage(), llmq::CInstantSendManager::ProcessInstantSendLock(), llmq::CQuorumBlockProcessor::ProcessMessage(), ProcessMessage(), llmq::CInstantSendManager::ProcessNewTransaction(), pruneblockchain(), CChainState::ReplayBlocks(), rescanblockchain(), CWallet::RescanFromTime(), CChainState::ResetBlockFailureFlags(), CChainState::RollforwardBlock(), RPCNotifyBlockChange(), CWallet::ScanForWalletTransactions(), PeerLogicValidation::SendMessages(), CDiskBlockIndex::SerializationOp(), SetNull(), CChain::SetTip(), SoftForkMajorityDesc(), TestBlockValidity(), ToString(), llmq::CChainLocksHandler::TrySignChainTip(), TxToJSON(), llmq::CQuorumBlockProcessor::UndoBlock(), CDeterministicMNManager::UndoBlock(), CDSNotificationInterface::UpdatedBlockTip(), PeerLogicValidation::UpdatedBlockTip(), CActiveMasternodeManager::UpdatedBlockTip(), llmq::CDKGSessionManager::UpdatedBlockTip(), CMasternodeSync::UpdatedBlockTip(), llmq::CDKGSessionHandler::UpdatedBlockTip(), llmq::CInstantSendManager::UpdatedBlockTip(), CPrivateSendClientManager::UpdatedBlockTip(), CGovernanceManager::UpdatedBlockTip(), UpdateMempoolForReorg(), UpdateTip(), CDeterministicMNManager::UpgradeDiff(), and CVerifyDB::VerifyDB().

◆ nMedianTimeSpan

constexpr int CBlockIndex::nMedianTimeSpan = 11
static

Definition at line 307 of file chain.h.

Referenced by GetMedianTimePast().

◆ nNonce

◆ nSequenceId

int32_t CBlockIndex::nSequenceId

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

Definition at line 217 of file chain.h.

Referenced by CChainState::AddToBlockIndex(), CChainState::CheckBlockIndex(), CChainState::PreciousBlock(), CChainState::ReceivedBlockTransactions(), and SetNull().

◆ nStatus

◆ nTime

◆ nTimeMax

unsigned int CBlockIndex::nTimeMax

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

Definition at line 220 of file chain.h.

Referenced by GetBlockTimeMax(), CChainState::LoadBlockIndex(), and SetNull().

◆ nTx

unsigned int CBlockIndex::nTx

◆ nUndoPos

unsigned int CBlockIndex::nUndoPos

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

Definition at line 192 of file chain.h.

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

◆ nVersion

◆ phashBlock

const uint256* CBlockIndex::phashBlock

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

Definition at line 174 of file chain.h.

Referenced by AddTx(), CheckForkWarningConditions(), CChainState::ConnectBlock(), GetBlockHash(), getchaintips(), CPrivateSendBroadcastTx::IsExpired(), and SetNull().

◆ pprev

CBlockIndex* CBlockIndex::pprev

pointer to the index of the predecessor of this block

Definition at line 177 of file chain.h.

Referenced by CChainState::AcceptBlock(), CChainState::AcceptBlockHeader(), CChainState::ActivateBestChainStep(), CWallet::BlockConnected(), blockheaderToJSON(), blockToJSON(), BuildSkip(), CDiskBlockIndex::CDiskBlockIndex(), llmq::CChainLocksHandler::CheckActiveState(), CChainState::CheckBlockIndex(), CheckCbTxMerkleRoots(), CheckForkWarningConditionsOnNewFork(), CheckSequenceLocks(), CDeterministicMNManager::CleanupCache(), WarningBitsConditionChecker::Condition(), CChainState::ConnectBlock(), CChainState::ConnectTip(), CWallet::CreateWalletFromFile(), DarkGravityWave(), CChainState::DisconnectBlock(), CChainState::DisconnectTip(), llmq::CChainLocksHandler::EnforceBestChainLock(), EvaluateSequenceLocks(), CChain::FindFork(), CChainState::FindMostWorkChain(), GetAncestor(), getblockchaininfo(), GetBlockHeader(), GetBlockScriptFlags(), getblockstats(), CDeterministicMNManager::GetListForBlock(), GetMedianTimePast(), GetNetworkHashPS(), GetNextWorkRequiredBTC(), AbstractThresholdConditionChecker::GetStateFor(), AbstractThresholdConditionChecker::GetStateStatisticsFor(), CChainState::InvalidateBlock(), KimotoGravityWell(), LastCommonAncestor(), listsinceblock(), CChainState::LoadBlockIndex(), CBlockTreeDB::LoadBlockIndexGuts(), PeerLogicValidation::NewPoWValidBlock(), CDeterministicMNManager::ProcessBlock(), ProcessHeadersMessage(), ProcessSpecialTxsInBlock(), PruneOneBlockFile(), CChainState::ReceivedBlockTransactions(), CChainState::ReplayBlocks(), rescanblockchain(), CChainState::ResetBlockFailureFlags(), PeerLogicValidation::SendMessages(), SetNull(), CChain::SetTip(), ToString(), llmq::CChainLocksHandler::TrySignChainTip(), llmq::CQuorumBlockProcessor::UndoBlock(), CDeterministicMNManager::UndoBlock(), CActiveMasternodeManager::UpdatedBlockTip(), PeerLogicValidation::UpdatedBlockTip(), llmq::CInstantSendManager::UpdatedBlockTip(), UpdateTip(), CVerifyDB::VerifyDB(), and WriteUndoDataForBlock().

◆ pskip

CBlockIndex* CBlockIndex::pskip

pointer to the index of some further predecessor of this block

Definition at line 180 of file chain.h.

Referenced by BuildSkip(), CChainState::CheckBlockIndex(), GetAncestor(), and SetNull().


The documentation for this class was generated from the following files:
Released under the MIT license