Bitcoin Core 28.99.0
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
CChain Class Reference

An in-memory indexed chain of blocks. More...

#include <chain.h>

Public Member Functions

 CChain ()=default
 
 CChain (const CChain &)=delete
 
CChainoperator= (const CChain &)=delete
 
CBlockIndexGenesis () const
 Returns the index entry for the genesis block of this chain, or nullptr if none. More...
 
CBlockIndexTip () const
 Returns the index entry for the tip of this chain, or nullptr if none. More...
 
CBlockIndexoperator[] (int nHeight) const
 Returns the index entry at a particular height in this chain, or nullptr if no such height exists. More...
 
bool Contains (const CBlockIndex *pindex) const
 Efficiently check whether a block is present in this chain. More...
 
CBlockIndexNext (const CBlockIndex *pindex) const
 Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip. More...
 
int Height () const
 Return the maximal height in the chain. More...
 
void SetTip (CBlockIndex &block)
 Set/initialize a chain with a given tip. More...
 
CBlockLocator GetLocator () const
 Return a CBlockLocator that refers to the tip in of this chain. More...
 
const CBlockIndexFindFork (const CBlockIndex *pindex) const
 Find the last common block between this chain and a block index entry. More...
 
CBlockIndexFindEarliestAtLeast (int64_t nTime, int height) const
 Find the earliest block with timestamp equal or greater than the given time and height equal or greater than the given height. More...
 

Private Attributes

std::vector< CBlockIndex * > vChain
 

Detailed Description

An in-memory indexed chain of blocks.

Definition at line 416 of file chain.h.

Constructor & Destructor Documentation

◆ CChain() [1/2]

CChain::CChain ( )
default

◆ CChain() [2/2]

CChain::CChain ( const CChain )
delete

Member Function Documentation

◆ Contains()

bool CChain::Contains ( const CBlockIndex pindex) const
inline

Efficiently check whether a block is present in this chain.

Definition at line 447 of file chain.h.

Here is the caller graph for this function:

◆ FindEarliestAtLeast()

CBlockIndex * CChain::FindEarliestAtLeast ( int64_t  nTime,
int  height 
) const

Find the earliest block with timestamp equal or greater than the given time and height equal or greater than the given height.

Definition at line 71 of file chain.cpp.

Here is the caller graph for this function:

◆ FindFork()

const CBlockIndex * CChain::FindFork ( const CBlockIndex pindex) const

Find the last common block between this chain and a block index entry.

Definition at line 60 of file chain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Genesis()

CBlockIndex * CChain::Genesis ( ) const
inline

Returns the index entry for the genesis block of this chain, or nullptr if none.

Definition at line 427 of file chain.h.

Here is the caller graph for this function:

◆ GetLocator()

CBlockLocator CChain::GetLocator ( ) const

Return a CBlockLocator that refers to the tip in of this chain.

Definition at line 55 of file chain.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Height()

int CChain::Height ( ) const
inline

Return the maximal height in the chain.

Is equal to chain.Tip() ? chain.Tip()->nHeight : -1.

Definition at line 462 of file chain.h.

Here is the caller graph for this function:

◆ Next()

CBlockIndex * CChain::Next ( const CBlockIndex pindex) const
inline

Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip.

Definition at line 453 of file chain.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

CChain & CChain::operator= ( const CChain )
delete

◆ operator[]()

CBlockIndex * CChain::operator[] ( int  nHeight) const
inline

Returns the index entry at a particular height in this chain, or nullptr if no such height exists.

Definition at line 439 of file chain.h.

◆ SetTip()

void CChain::SetTip ( CBlockIndex block)

Set/initialize a chain with a given tip.

Definition at line 21 of file chain.cpp.

Here is the caller graph for this function:

◆ Tip()

CBlockIndex * CChain::Tip ( ) const
inline

Returns the index entry for the tip of this chain, or nullptr if none.

Definition at line 433 of file chain.h.

Here is the caller graph for this function:

Member Data Documentation

◆ vChain

std::vector<CBlockIndex*> CChain::vChain
private

Definition at line 419 of file chain.h.


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