Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CBlockIndex Class Reference

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 <main.h>

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

Public Types

enum  { nMedianTimeSpan =11 }
 

Public Member Functions

 CBlockIndex ()
 
 CBlockIndex (CBlockHeader &block)
 
CDiskBlockPos GetBlockPos () const
 
CDiskBlockPos GetUndoPos () const
 
CBlockHeader GetBlockHeader () const
 
uint256 GetBlockHash () const
 
int64_t GetBlockTime () const
 
CBigNum GetBlockWork () const
 
bool CheckIndex () const
 
int64_t GetMedianTimePast () const
 
int64_t GetMedianTime () const
 
std::string ToString () const
 
void print () const
 

Static Public Member Functions

static bool IsSuperMajority (int minVersion, const CBlockIndex *pstart, unsigned int nRequired, unsigned int nToCheck)
 Returns true if there are nRequired or more blocks of minVersion or above in the last nToCheck blocks, starting at pstart and going backwards. More...
 

Public Attributes

const uint256phashBlock
 
CBlockIndexpprev
 
int nHeight
 
int nFile
 
unsigned int nDataPos
 
unsigned int nUndoPos
 
uint256 nChainWork
 
unsigned int nTx
 
unsigned int nChainTx
 
unsigned int nStatus
 
int nVersion
 
uint256 hashMerkleRoot
 
unsigned int nTime
 
unsigned int nBits
 
unsigned int nNonce
 
uint32_t nSequenceId
 

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 688 of file main.h.

Member Enumeration Documentation

anonymous enum
Enumerator
nMedianTimeSpan 

Definition at line 829 of file main.h.

Constructor & Destructor Documentation

CBlockIndex::CBlockIndex ( )
inline

Definition at line 732 of file main.h.

CBlockIndex::CBlockIndex ( CBlockHeader block)
inline

Member Function Documentation

bool CBlockIndex::CheckIndex ( ) const
inline

Definition at line 824 of file main.h.

References CheckProofOfWork(), and GetBlockHash().

Referenced by CBlockTreeDB::LoadBlockIndexGuts().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint256 CBlockIndex::GetBlockHash ( ) const
inline
CBlockHeader CBlockIndex::GetBlockHeader ( ) const
inline

Definition at line 792 of file main.h.

References GetBlockHash(), CBlockHeader::hashMerkleRoot, hashMerkleRoot, CBlockHeader::hashPrevBlock, CBlockHeader::nBits, nBits, CBlockHeader::nNonce, nNonce, CBlockHeader::nTime, nTime, CBlockHeader::nVersion, and nVersion.

Referenced by ProcessMessage().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CDiskBlockPos CBlockIndex::GetBlockPos ( ) const
inline

Definition at line 774 of file main.h.

References BLOCK_HAVE_DATA, nDataPos, CDiskBlockPos::nFile, nFile, and CDiskBlockPos::nPos.

Referenced by ConnectBlock(), PrintBlockTree(), and ReadBlockFromDisk().

+ Here is the caller graph for this function:

int64_t CBlockIndex::GetBlockTime ( ) const
inline

Definition at line 810 of file main.h.

References nTime.

Referenced by mastercore::eraseExpiredCrowdsale(), CMPMetaDEx::getBlockTime(), ClientModel::getLastBlockDate(), mastercore::GetLatestBlockTime(), GetMedianTimePast(), GetNetworkHashPS(), GetNextWorkRequired(), InvalidChainFound(), IsInitialBlockDownload(), LoadBlockIndexDB(), mastercore_handler_block_end(), mastercore_handler_tx(), CMPTxList::setLastAlert(), and UpdateTip().

+ Here is the caller graph for this function:

CBigNum CBlockIndex::GetBlockWork ( ) const
inline

Definition at line 815 of file main.h.

References CBigNum::SetCompact().

Referenced by AddToBlockIndex(), CheckForkWarningConditions(), CheckForkWarningConditionsOnNewFork(), and LoadBlockIndexDB().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t CBlockIndex::GetMedianTime ( ) const

Definition at line 2517 of file main.cpp.

References AssertLockHeld, GetMedianTimePast(), and CChain::Next().

+ Here is the call graph for this function:

int64_t CBlockIndex::GetMedianTimePast ( ) const
inline

Definition at line 831 of file main.h.

References GetBlockTime(), nMedianTimeSpan, and pprev.

Referenced by AcceptBlock(), getblocktemplate(), GetMedianTime(), and UpdateTime().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CDiskBlockPos CBlockIndex::GetUndoPos ( ) const
inline

Definition at line 783 of file main.h.

References BLOCK_HAVE_UNDO, CDiskBlockPos::nFile, nFile, CDiskBlockPos::nPos, and nUndoPos.

Referenced by ConnectBlock(), DisconnectBlock(), and VerifyDB().

+ Here is the caller graph for this function:

bool CBlockIndex::IsSuperMajority ( int  minVersion,
const CBlockIndex pstart,
unsigned int  nRequired,
unsigned int  nToCheck 
)
static

Returns true if there are nRequired or more blocks of minVersion or above in the last nToCheck blocks, starting at pstart and going backwards.

Definition at line 2505 of file main.cpp.

References nVersion, and pprev.

Referenced by AcceptBlock().

+ Here is the caller graph for this function:

void CBlockIndex::print ( ) const
inline

Definition at line 862 of file main.h.

References LogPrintf, and ToString().

+ Here is the call graph for this function:

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

Definition at line 854 of file main.h.

References GetBlockHash(), strprintf, and base_uint< BITS >::ToString().

Referenced by CBlockTreeDB::LoadBlockIndexGuts(), print(), prune_state_files(), and CDiskBlockIndex::ToString().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

uint256 CBlockIndex::hashMerkleRoot
unsigned int CBlockIndex::nBits
unsigned int CBlockIndex::nChainTx
uint256 CBlockIndex::nChainWork
unsigned int CBlockIndex::nDataPos

Definition at line 704 of file main.h.

Referenced by AddToBlockIndex(), GetBlockPos(), and CBlockTreeDB::LoadBlockIndexGuts().

int CBlockIndex::nFile
int CBlockIndex::nHeight
unsigned int CBlockIndex::nNonce

Definition at line 727 of file main.h.

Referenced by GetBlockHeader(), and CBlockTreeDB::LoadBlockIndexGuts().

uint32_t CBlockIndex::nSequenceId

Definition at line 730 of file main.h.

Referenced by AddToBlockIndex().

unsigned int CBlockIndex::nStatus
unsigned int CBlockIndex::nTime
unsigned int CBlockIndex::nTx

Definition at line 714 of file main.h.

Referenced by AddToBlockIndex(), LoadBlockIndexDB(), and CBlockTreeDB::LoadBlockIndexGuts().

unsigned int CBlockIndex::nUndoPos
int CBlockIndex::nVersion
const uint256* CBlockIndex::phashBlock
CBlockIndex* CBlockIndex::pprev

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