MCPcopy Create free account
hub / github.com/ElementsProject/elements / CBlockIndex

Class CBlockIndex

src/chain.h:154–440  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

152 * to it, but at most one of them can be part of the currently active branch.
153 */
154class CBlockIndex
155{
156public:
157 //! pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
158 const uint256* phashBlock{nullptr};
159
160 //! pointer to the index of the predecessor of this block
161 CBlockIndex* pprev{nullptr};
162
163 //! pointer to the index of some further predecessor of this block
164 CBlockIndex* pskip{nullptr};
165
166 //! height of the entry in the chain. The genesis block has height 0
167 int nHeight{0};
168
169 //! Which # file this block is stored in (blk?????.dat)
170 int nFile GUARDED_BY(::cs_main){0};
171
172 //! Byte offset within blk?????.dat where this block's data is stored
173 unsigned int nDataPos GUARDED_BY(::cs_main){0};
174
175 //! Byte offset within rev?????.dat where this block's undo data is stored
176 unsigned int nUndoPos GUARDED_BY(::cs_main){0};
177
178 //! (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block
179 arith_uint256 nChainWork{};
180
181 //! Number of transactions in this block.
182 //! Note: in a potential headers-first mode, this number cannot be relied upon
183 //! Note: this value is faked during UTXO snapshot load to ensure that
184 //! LoadBlockIndex() will load index entries for blocks that we lack data for.
185 //! @sa ActivateSnapshot
186 unsigned int nTx{0};
187
188 //! (memory only) Number of transactions in the chain up to and including this block.
189 //! This value will be non-zero only if and only if transactions for this block and all its parents are available.
190 //! Change to 64-bit type before 2024 (assuming worst case of 60 byte transactions).
191 //!
192 //! Note: this value is faked during use of a UTXO snapshot because we don't
193 //! have the underlying block data available during snapshot load.
194 //! @sa AssumeutxoData
195 //! @sa ActivateSnapshot
196 unsigned int nChainTx{0};
197
198 //! Verification status of this block. See enum BlockStatus
199 //!
200 //! Note: this value is modified to show BLOCK_OPT_WITNESS during UTXO snapshot
201 //! load to avoid the block index being spuriously rewound.
202 //! @sa NeedsRedownload
203 //! @sa ActivateSnapshot
204 uint32_t nStatus GUARDED_BY(::cs_main){0};
205
206 //! block header
207 int32_t nVersion{0};
208 uint256 hashMerkleRoot{};
209 uint32_t nTime{0};
210 uint32_t nBits{0};
211 uint32_t nNonce{0};

Callers

nothing calls this directly

Calls 1

valueMethod · 0.45

Tested by

no test coverage detected