Changeset View
Changeset View
Standalone View
Standalone View
src/blockindex.h
Show All 18 Lines | |||||
* the root, with each block potentially having multiple candidates to be the | * 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 | * 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. | * one of them can be part of the currently active branch. | ||||
*/ | */ | ||||
class CBlockIndex { | class CBlockIndex { | ||||
public: | public: | ||||
//! pointer to the hash of the block, if any. Memory is owned by this | //! pointer to the hash of the block, if any. Memory is owned by this | ||||
//! CBlockIndex | //! CBlockIndex | ||||
const BlockHash *phashBlock = nullptr; | const BlockHash *phashBlock{nullptr}; | ||||
//! pointer to the index of the predecessor of this block | //! pointer to the index of the predecessor of this block | ||||
CBlockIndex *pprev = nullptr; | CBlockIndex *pprev{nullptr}; | ||||
//! pointer to the index of some further predecessor of this block | //! pointer to the index of some further predecessor of this block | ||||
CBlockIndex *pskip = nullptr; | CBlockIndex *pskip{nullptr}; | ||||
//! height of the entry in the chain. The genesis block has height 0 | //! height of the entry in the chain. The genesis block has height 0 | ||||
int nHeight = 0; | int nHeight{0}; | ||||
//! Which # file this block is stored in (blk?????.dat) | //! Which # file this block is stored in (blk?????.dat) | ||||
int nFile = 0; | int nFile{0}; | ||||
//! Byte offset within blk?????.dat where this block's data is stored | //! Byte offset within blk?????.dat where this block's data is stored | ||||
unsigned int nDataPos = 0; | unsigned int nDataPos{0}; | ||||
//! Byte offset within rev?????.dat where this block's undo data is stored | //! Byte offset within rev?????.dat where this block's undo data is stored | ||||
unsigned int nUndoPos = 0; | unsigned int nUndoPos{0}; | ||||
//! (memory only) Total amount of work (expected number of hashes) in the | //! (memory only) Total amount of work (expected number of hashes) in the | ||||
//! chain up to and including this block | //! chain up to and including this block | ||||
arith_uint256 nChainWork = arith_uint256(); | arith_uint256 nChainWork{}; | ||||
//! Number of transactions in this block. | //! Number of transactions in this block. | ||||
//! Note: in a potential headers-first mode, this number cannot be relied | //! Note: in a potential headers-first mode, this number cannot be relied | ||||
//! upon | //! upon | ||||
unsigned int nTx = 0; | unsigned int nTx{0}; | ||||
//! Size of this block. | //! Size of this block. | ||||
//! Note: in a potential headers-first mode, this number cannot be relied | //! Note: in a potential headers-first mode, this number cannot be relied | ||||
//! upon | //! upon | ||||
unsigned int nSize = 0; | unsigned int nSize{0}; | ||||
private: | private: | ||||
//! (memory only) Number of transactions in the chain up to and including | //! (memory only) Number of transactions in the chain up to and including | ||||
//! this block. | //! this block. | ||||
//! This value will be non-zero only if and only if transactions for this | //! 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 | //! block and all its parents are available. Change to 64-bit type when | ||||
//! necessary; won't happen before 2030 | //! necessary; won't happen before 2030 | ||||
unsigned int nChainTx = 0; | unsigned int nChainTx{0}; | ||||
//! (memory only) Size of all blocks in the chain up to and including this | //! (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 | //! block. This value will be non-zero only if and only if transactions for | ||||
//! this block and all its parents are available. | //! this block and all its parents are available. | ||||
uint64_t nChainSize = 0; | uint64_t nChainSize{0}; | ||||
public: | public: | ||||
//! Verification status of this block. See enum BlockStatus | //! Verification status of this block. See enum BlockStatus | ||||
BlockStatus nStatus = BlockStatus(); | BlockStatus nStatus{}; | ||||
//! block header | //! block header | ||||
int32_t nVersion = 0; | int32_t nVersion{0}; | ||||
uint256 hashMerkleRoot = uint256(); | uint256 hashMerkleRoot{}; | ||||
uint32_t nTime = 0; | uint32_t nTime{0}; | ||||
uint32_t nBits = 0; | uint32_t nBits{0}; | ||||
uint32_t nNonce = 0; | uint32_t nNonce{0}; | ||||
//! (memory only) Sequential id assigned to distinguish order in which | //! (memory only) Sequential id assigned to distinguish order in which | ||||
//! blocks are received. | //! blocks are received. | ||||
int32_t nSequenceId = 0; | int32_t nSequenceId{0}; | ||||
//! (memory only) block header metadata | //! (memory only) block header metadata | ||||
uint64_t nTimeReceived = 0; | uint64_t nTimeReceived{0}; | ||||
//! (memory only) Maximum nTime in the chain up to and including this block. | //! (memory only) Maximum nTime in the chain up to and including this block. | ||||
unsigned int nTimeMax = 0; | unsigned int nTimeMax{0}; | ||||
explicit CBlockIndex() = default; | explicit CBlockIndex() = default; | ||||
explicit CBlockIndex(const CBlockHeader &block) : CBlockIndex() { | explicit CBlockIndex(const CBlockHeader &block) | ||||
nVersion = block.nVersion; | : nVersion{block.nVersion}, hashMerkleRoot{block.hashMerkleRoot}, | ||||
hashMerkleRoot = block.hashMerkleRoot; | nTime{block.nTime}, nBits{block.nBits}, nNonce{block.nNonce}, | ||||
nTime = block.nTime; | nTimeReceived{0} {} | ||||
nTimeReceived = 0; | |||||
nBits = block.nBits; | |||||
nNonce = block.nNonce; | |||||
} | |||||
FlatFilePos GetBlockPos() const { | FlatFilePos GetBlockPos() const { | ||||
FlatFilePos ret; | FlatFilePos ret; | ||||
if (nStatus.hasData()) { | if (nStatus.hasData()) { | ||||
ret.nFile = nFile; | ret.nFile = nFile; | ||||
ret.nPos = nDataPos; | ret.nPos = nDataPos; | ||||
} | } | ||||
return ret; | return ret; | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |