![]() |
Bitcoin Core
24.99.0
P2P Digital Currency
|
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>
Public Member Functions | |
int nFile | GUARDED_BY (::cs_main) |
Which # file this block is stored in (blk?????.dat) More... | |
unsigned int nDataPos | GUARDED_BY (::cs_main) |
Byte offset within blk?????.dat where this block's data is stored. More... | |
unsigned int nUndoPos | GUARDED_BY (::cs_main) |
Byte offset within rev?????.dat where this block's undo data is stored. More... | |
uint32_t nStatus | GUARDED_BY (::cs_main) |
Verification status of this block. More... | |
CBlockIndex (const CBlockHeader &block) | |
FlatFilePos | GetBlockPos () const EXCLUSIVE_LOCKS_REQUIRED( |
FlatFilePos | GetUndoPos () const EXCLUSIVE_LOCKS_REQUIRED( |
CBlockHeader | GetBlockHeader () const |
uint256 | GetBlockHash () const |
bool | HaveTxsDownloaded () const |
Check whether this block's and all previous blocks' transactions have been downloaded (and stored to disk) at some point. More... | |
NodeSeconds | Time () 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 EXCLUSIVE_LOCKS_REQUIRED( |
Check whether this block index entry is valid up to the passed validity level. More... | |
bool | IsAssumedValid () const EXCLUSIVE_LOCKS_REQUIRED( |
bool | RaiseValidity (enum BlockStatus nUpTo) EXCLUSIVE_LOCKS_REQUIRED( |
Raise the validity level of this block index entry. More... | |
void | BuildSkip () |
Build the skiplist pointer for this entry. More... | |
CBlockIndex * | GetAncestor (int height) |
Efficiently find an ancestor of this block. More... | |
const CBlockIndex * | GetAncestor (int height) const |
CBlockIndex ()=default | |
~CBlockIndex ()=default | |
Public Attributes | |
const uint256 * | phashBlock {nullptr} |
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex More... | |
CBlockIndex * | pprev {nullptr} |
pointer to the index of the predecessor of this block More... | |
CBlockIndex * | pskip {nullptr} |
pointer to the index of some further predecessor of this block More... | |
int | nHeight {0} |
height of the entry in the chain. The genesis block has height 0 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 {0} |
Number of transactions in this block. More... | |
unsigned int | nChainTx {0} |
(memory only) Number of transactions in the chain up to and including this block. More... | |
int32_t | nVersion {0} |
block header More... | |
uint256 | hashMerkleRoot {} |
uint32_t | nTime {0} |
uint32_t | nBits {0} |
uint32_t | nNonce {0} |
int32_t | nSequenceId {0} |
(memory only) Sequential id assigned to distinguish order in which blocks are received. More... | |
unsigned int | nTimeMax {0} |
(memory only) Maximum nTime in the chain up to and including this block. More... | |
Static Public Attributes | |
static constexpr int | nMedianTimeSpan = 11 |
Protected Member Functions | |
CBlockIndex (const CBlockIndex &)=default | |
CBlockIndex should not allow public copy construction because equality comparison via pointer is very common throughout the codebase, making use of copy a footgun. More... | |
CBlockIndex & | operator= (const CBlockIndex &)=delete |
CBlockIndex (CBlockIndex &&)=delete | |
CBlockIndex & | operator= (CBlockIndex &&)=delete |
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.
|
inlineexplicit |
|
default |
|
default |
|
protecteddefault |
CBlockIndex should not allow public copy construction because equality comparison via pointer is very common throughout the codebase, making use of copy a footgun.
Also, use of copies do not have the benefit of simplifying lifetime considerations due to attributes like pprev and pskip, which are at risk of becoming dangling pointers in a copied instance.
We declare these protected instead of simply deleting them so that CDiskBlockIndex can reuse copy construction.
|
protecteddelete |
void CBlockIndex::BuildSkip | ( | ) |
CBlockIndex * CBlockIndex::GetAncestor | ( | int | height | ) |
const CBlockIndex * CBlockIndex::GetAncestor | ( | int | height | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Check whether this block's and all previous blocks' transactions have been downloaded (and stored to disk) at some point.
Does not imply the transactions are consensus-valid (ConnectTip might fail) Does not imply the transactions are still stored on disk. (IsBlockPruned might return true)
Definition at line 272 of file chain.h.
|
inline |
|
inline |
|
protecteddelete |
|
protecteddelete |
|
inline |
|
inline |
std::string CBlockIndex::ToString | ( | ) | const |
unsigned int CBlockIndex::nChainTx {0} |
(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 before 2024 (assuming worst case of 60 byte transactions).
Note: this value is faked during use of a UTXO snapshot because we don't have the underlying block data available during snapshot load.
arith_uint256 CBlockIndex::nChainWork {} |
int CBlockIndex::nHeight {0} |
|
staticconstexpr |
int32_t CBlockIndex::nSequenceId {0} |
unsigned int CBlockIndex::nTimeMax {0} |
unsigned int CBlockIndex::nTx {0} |
Number of transactions in this block.
Note: in a potential headers-first mode, this number cannot be relied upon Note: this value is faked during UTXO snapshot load to ensure that LoadBlockIndex() will load index entries for blocks that we lack data for.
const uint256* CBlockIndex::phashBlock {nullptr} |
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
CBlockIndex* CBlockIndex::pprev {nullptr} |
CBlockIndex* CBlockIndex::pskip {nullptr} |