Bitcoin ABC 0.30.5
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 <blockindex.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... | |
BlockStatus nStatus | GUARDED_BY (::cs_main) |
Verification status of this block. See enum BlockStatus. More... | |
CBlockIndex ()=default | |
CBlockIndex (const CBlockHeader &block) | |
FlatFilePos | GetBlockPos () const EXCLUSIVE_LOCKS_REQUIRED( |
FlatFilePos | GetUndoPos () const EXCLUSIVE_LOCKS_REQUIRED( |
CBlockHeader | GetBlockHeader () const |
BlockHash | GetBlockHash () const |
int64_t | GetChainTxCount () const |
Get the number of transaction in the chain so far. More... | |
uint64_t | GetChainSize () const |
Get the size of all the blocks in the chain so far. More... | |
bool | UpdateChainStats () |
Update chain tx stats. More... | |
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 | GetHeaderReceivedTime () const |
int64_t | GetReceivedTimeDiff () const |
int64_t | GetMedianTimePast () const |
std::string | ToString () const |
bool | IsValid (enum BlockValidity nUpTo=BlockValidity::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 BlockValidity 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 |
Public Attributes | |
const BlockHash * | phashBlock {nullptr} |
pointer to the hash of the block, if any. 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 | nSize {0} |
Size of 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... | |
int64_t | nTimeReceived {0} |
(memory only) block header metadata 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 |
Private Attributes | |
uint64_t | nChainSize {0} |
(memory only) Size of all blocks in the chain up to and including this block. More... | |
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 25 of file blockindex.h.
|
explicitdefault |
|
inlineexplicit |
Definition at line 108 of file blockindex.h.
void CBlockIndex::BuildSkip | ( | ) |
Build the skiplist pointer for this entry.
Definition at line 83 of file blockindex.cpp.
CBlockIndex * CBlockIndex::GetAncestor | ( | int | height | ) |
Efficiently find an ancestor of this block.
Definition at line 78 of file blockindex.cpp.
const CBlockIndex * CBlockIndex::GetAncestor | ( | int | height | ) | const |
|
inline |
|
inline |
Definition at line 133 of file blockindex.h.
|
inline |
Definition at line 113 of file blockindex.h.
|
inline |
|
inline |
|
inline |
Get the size of all the blocks in the chain so far.
Definition at line 159 of file blockindex.h.
|
inline |
Get the number of transaction in the chain so far.
Definition at line 154 of file blockindex.h.
|
inline |
|
inline |
Definition at line 192 of file blockindex.h.
|
inline |
Definition at line 186 of file blockindex.h.
|
inline |
Definition at line 123 of file blockindex.h.
|
inline |
Which # file this block is stored in (blk?????.dat)
Definition at line 41 of file blockindex.h.
|
inline |
Byte offset within blk?????.dat where this block's data is stored.
Definition at line 44 of file blockindex.h.
|
inline |
Byte offset within rev?????.dat where this block's undo data is stored.
Definition at line 47 of file blockindex.h.
|
inline |
Verification status of this block. See enum BlockStatus.
Definition at line 87 of file blockindex.h.
|
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 174 of file blockindex.h.
|
inline |
Definition at line 219 of file blockindex.h.
|
inline |
Check whether this block index entry is valid up to the passed validity level.
Definition at line 211 of file blockindex.h.
|
inline |
Raise the validity level of this block index entry.
Returns true if the validity was changed.
Definition at line 226 of file blockindex.h.
|
inline |
std::string CBlockIndex::ToString | ( | ) | const |
Definition at line 28 of file blockindex.cpp.
bool CBlockIndex::UpdateChainStats | ( | ) |
Update chain tx stats.
Definition at line 34 of file blockindex.cpp.
uint256 CBlockIndex::hashMerkleRoot {} |
Definition at line 91 of file blockindex.h.
uint32_t CBlockIndex::nBits {0} |
Definition at line 93 of file blockindex.h.
|
private |
(memory only) Size of all blocks 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.
Definition at line 83 of file blockindex.h.
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 when necessary; won't happen before 2030
Note: this value is faked during use of a UTXO snapshot because we don't have the underlying block data available during snapshot load.
Definition at line 77 of file blockindex.h.
arith_uint256 CBlockIndex::nChainWork {} |
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this block
Definition at line 51 of file blockindex.h.
int CBlockIndex::nHeight {0} |
height of the entry in the chain. The genesis block has height 0
Definition at line 38 of file blockindex.h.
|
staticconstexpr |
Definition at line 190 of file blockindex.h.
uint32_t CBlockIndex::nNonce {0} |
Definition at line 94 of file blockindex.h.
int32_t CBlockIndex::nSequenceId {0} |
(memory only) Sequential id assigned to distinguish order in which blocks are received.
Definition at line 98 of file blockindex.h.
unsigned int CBlockIndex::nSize {0} |
Size of this block.
Note: in a potential headers-first mode, this number cannot be relied upon
Definition at line 65 of file blockindex.h.
uint32_t CBlockIndex::nTime {0} |
Definition at line 92 of file blockindex.h.
unsigned int CBlockIndex::nTimeMax {0} |
(memory only) Maximum nTime in the chain up to and including this block.
Definition at line 104 of file blockindex.h.
int64_t CBlockIndex::nTimeReceived {0} |
(memory only) block header metadata
Definition at line 101 of file blockindex.h.
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.
Definition at line 60 of file blockindex.h.
int32_t CBlockIndex::nVersion {0} |
block header
Definition at line 90 of file blockindex.h.
const BlockHash* CBlockIndex::phashBlock {nullptr} |
pointer to the hash of the block, if any.
Memory is owned by this CBlockIndex
Definition at line 29 of file blockindex.h.
CBlockIndex* CBlockIndex::pprev {nullptr} |
pointer to the index of the predecessor of this block
Definition at line 32 of file blockindex.h.
CBlockIndex* CBlockIndex::pskip {nullptr} |
pointer to the index of some further predecessor of this block
Definition at line 35 of file blockindex.h.