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

source

pub fn new(block: &BlockHeader) -> Self

source

pub fn get_block_pos(&self) -> FlatFilePos

source

pub fn get_undo_pos(&self) -> FlatFilePos

source

pub fn get_block_header(&self) -> BlockHeader

source

pub fn get_block_hash(&self) -> u256

source

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) |

source

pub fn get_block_time(&self) -> i64

source

pub fn get_block_time_max(&self) -> i64

source

pub fn get_median_time_past(self: Arc<Self>) -> i64

source

pub fn to_string(&self) -> String

source

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

source

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.

source

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.

source

pub fn get_n_status(&self) -> BlockStatus

source

pub fn get_ancestor(self: Arc<Self>, height: i32) -> Option<Arc<BlockIndex>>

| Efficiently find an ancestor of this | block. |

source

pub fn build_skip(&mut self)

| Build the skiplist pointer for this | entry. |

Trait Implementations§

source§

impl Clone for BlockIndex

source§

fn clone(&self) -> BlockIndex

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for BlockIndex

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for BlockIndex

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq<BlockIndex> for BlockIndex

source§

fn eq(&self, other: &BlockIndex) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for BlockIndex

source§

impl Send for BlockIndex

source§

impl StructuralEq for BlockIndex

source§

impl StructuralPartialEq for BlockIndex

source§

impl Sync for BlockIndex

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, U> CastInto<U> for Twhere U: CastFrom<T>,

§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> StaticUpcast<T> for T

§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V