Struct bitcoin_block::BlockIndex
source · pub struct BlockIndex {Show 18 fields
pub phash_block: Option<u256>,
pub pprev: Option<Arc<BlockIndex>>,
pub pskip: Option<Arc<BlockIndex>>,
pub n_height: i32,
pub n_file: i32,
pub n_data_pos: u32,
pub n_undo_pos: u32,
pub n_chain_work: ArithU256,
pub n_tx: u32,
pub n_chain_tx: u32,
pub n_status: u32,
pub n_version: i32,
pub hash_merkle_root: u256,
pub n_time: u32,
pub n_bits: u32,
pub n_nonce: u32,
pub n_sequence_id: i32,
pub n_time_max: u32,
}Expand 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. |
Fields§
§phash_block: Option<u256>| pointer to the hash of the block, if any. | Memory is owned by this CBlockIndex |
pprev: Option<Arc<BlockIndex>>| pointer to the index of the predecessor | of this block |
pskip: Option<Arc<BlockIndex>>| pointer to the index of some further | predecessor of this block |
n_height: i32| height of the entry in the chain. The | genesis block has height 0 |
n_file: i32| Which # file this block is stored in (blk?????.dat) |
n_data_pos: u32| Byte offset within blk?????.dat where | this block’s data is stored |
n_undo_pos: u32| Byte offset within rev?????.dat where | this block’s undo data is stored |
n_chain_work: ArithU256| (memory only) Total amount of work (expected | number of hashes) in the chain up to and | including this block |
n_tx: u32| 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. | | @sa ActivateSnapshot
n_chain_tx: u32| (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. | | @sa AssumeutxoData @sa ActivateSnapshot
n_status: u32| Verification status of this block. See enum | BlockStatus | | Note: this value is modified to show | BLOCK_OPT_WITNESS during UTXO snapshot load | to avoid the block index being spuriously | rewound. | | @sa NeedsRedownload @sa ActivateSnapshot
n_version: i32| block header |
hash_merkle_root: u256§n_time: u32§n_bits: u32§n_nonce: u32§n_sequence_id: i32| (memory only) Sequential id assigned | to distinguish order in which blocks | are received. |
n_time_max: u32| (memory only) Maximum nTime in the chain | up to and including this block. |
Implementations§
source§impl BlockIndex
impl BlockIndex
pub fn new(block: &BlockHeader) -> Self
pub fn get_block_pos(&self) -> FlatFilePos
pub fn get_undo_pos(&self) -> FlatFilePos
pub fn get_block_header(&self) -> BlockHeader
pub fn get_block_hash(&self) -> u256
sourcepub fn have_txs_downloaded(&self) -> bool
pub fn have_txs_downloaded(&self) -> bool
| 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) |
pub fn get_block_time(&self) -> i64
pub fn get_block_time_max(&self) -> i64
pub fn get_median_time_past(self: Arc<Self>) -> i64
pub fn to_string(&self) -> String
sourcepub fn is_valid(&self, n_up_to: Option<BlockStatus>) -> bool
pub fn is_valid(&self, n_up_to: Option<BlockStatus>) -> bool
| Check whether this block index entry | is valid up to the passed validity level. |
sourcepub fn is_assumed_valid(&self) -> bool
pub fn is_assumed_valid(&self) -> bool
| @returns true if the block is | assumed-valid; this means it is queued | to be validated by a background | chainstate.
sourcepub fn raise_validity(&mut self, n_up_to: BlockStatus) -> bool
pub fn raise_validity(&mut self, n_up_to: BlockStatus) -> bool
| Raise the validity level of this block | index entry. | | Returns true if the validity was changed.
pub fn get_n_status(&self) -> BlockStatus
sourcepub fn get_ancestor(self: Arc<Self>, height: i32) -> Option<Arc<BlockIndex>>
pub fn get_ancestor(self: Arc<Self>, height: i32) -> Option<Arc<BlockIndex>>
| Efficiently find an ancestor of this | block. |
sourcepub fn build_skip(&mut self)
pub fn build_skip(&mut self)
| Build the skiplist pointer for this | entry. |
Trait Implementations§
source§impl Clone for BlockIndex
impl Clone for BlockIndex
source§fn clone(&self) -> BlockIndex
fn clone(&self) -> BlockIndex
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for BlockIndex
impl Debug for BlockIndex
source§impl Default for BlockIndex
impl Default for BlockIndex
source§impl PartialEq<BlockIndex> for BlockIndex
impl PartialEq<BlockIndex> for BlockIndex
source§fn eq(&self, other: &BlockIndex) -> bool
fn eq(&self, other: &BlockIndex) -> bool
self and other values to be equal, and is used
by ==.impl Eq for BlockIndex
impl Send for BlockIndex
impl StructuralEq for BlockIndex
impl StructuralPartialEq for BlockIndex
impl Sync for BlockIndex
Auto Trait Implementations§
Blanket Implementations§
§impl<T, U> CastInto<U> for Twhere
U: CastFrom<T>,
impl<T, U> CastInto<U> for Twhere U: CastFrom<T>,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.