Bitcoin
Public Member Functions | Private Attributes | Friends | List of all members
CChain Class Reference

#include <chain.h>

Public Member Functions

CBlockIndexGenesis () const
 
CBlockIndexTip () const
 
CBlockIndexoperator[] (int nHeight) const
 
bool Contains (const CBlockIndex *pindex) const
 
CBlockIndexNext (const CBlockIndex *pindex) const
 
int Height () const
 
void SetTip (CBlockIndex *pindex)
 
CBlockLocator GetLocator (const CBlockIndex *pindex=nullptr) const
 
const CBlockIndexFindFork (const CBlockIndex *pindex) const
 
CBlockIndexFindEarliestAtLeast (int64_t nTime, int height) const
 

Private Attributes

std::vector< CBlockIndex * > vChain
 

Friends

bool operator== (const CChain &a, const CChain &b)
 

Detailed Description

An in-memory indexed chain of blocks.

Member Function Documentation

◆ Contains()

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

Efficiently check whether a block is present in this chain.

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

◆ FindFork()

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

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

◆ Genesis()

CBlockIndex* CChain::Genesis ( ) const
inline

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

◆ GetLocator()

CBlockLocator CChain::GetLocator ( const CBlockIndex pindex = nullptr) const

Return a CBlockLocator that refers to a block in this chain (by default the tip).

◆ Height()

int CChain::Height ( ) const
inline

Return the maximal height in the chain. Is equal to chain.Tip() ? chain.Tip()->nHeight : -1.

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

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

◆ SetTip()

void CChain::SetTip ( CBlockIndex pindex)

Set/initialize a chain with a given tip.

CChain implementation

◆ Tip()

CBlockIndex* CChain::Tip ( ) const
inline

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

Friends And Related Function Documentation

◆ operator==

bool operator== ( const CChain a,
const CChain b 
)
friend

Compare two chains efficiently.

Member Data Documentation

◆ vChain

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

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