Skip to main content

Header

Enum Header 

Source
pub enum Header {
    Stock(StockHeader),
    Blake2bV2(Blake2bV2Header),
}
Expand description

A header of either family, with the operations a sidestr validator needs dispatched to the right one.

Variants§

§

Stock(StockHeader)

An 80-byte stock header.

§

Blake2bV2(Blake2bV2Header)

A 164-byte Knots v2 header.

Implementations§

Source§

impl Header

Source

pub const fn family(&self) -> HeaderFamily

Which family this header belongs to.

Source

pub const fn version(&self) -> u32

The raw wire version.

Source

pub const fn prev_block_hash(&self) -> BlockHash

The previous block’s hash.

Source

pub const fn merkle_root(&self) -> [u8; 32]

The merkle root, wire order.

Source

pub fn time(&self) -> u32

The consensus block time (for v2, with the offset applied when flagged).

Source

pub const fn bits(&self) -> u32

Compact target.

Source

pub const fn nonce(&self) -> u32

The (first) nonce.

Source

pub const fn height(&self) -> Option<u32>

The committed height: a v2 header carries it, a stock header does not (siding’s blockHeight then reads the coinbase’s BIP 34 push, which is sidestr-core’s job).

Source

pub fn hash(&self) -> BlockHash

The block hash — the family’s proof-of-work hash, display order.

Source

pub fn encode(&self) -> EncodedHeader

The wire bytes.

Source

pub fn target(&self) -> Result<Target, Error>

The target bits encodes.

Source

pub fn meets_target(&self) -> bool

hash ≤ target(bits).

Source

pub fn check_pow(&self, pow_limit: &Target) -> Result<(), Error>

SPEC 4 step 1 against the chain document’s powLimit; see check_pow.

Source

pub fn signet_preimage(&self, stripped_merkle_root: [u8; 32]) -> [u8; 72]

The 72-byte BIP-325 preimage with the stripped merkle root in place.

Source

pub fn block_data(&self, stripped_merkle_root: [u8; 32]) -> [u8; 32]

The BIP-325 block data the block signature commits to (SPEC 4 step 2).

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Header

Source§

impl Debug for Header

Source§

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

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

impl Eq for Header

Source§

impl PartialEq for Header

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Header

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

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

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where 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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.