Struct sp_runtime::generic::Header
source · [−]pub struct Header<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> {
pub parent_hash: Hash::Output,
pub number: Number,
pub state_root: Hash::Output,
pub extrinsics_root: Hash::Output,
pub digest: Digest<Hash::Output>,
}
Expand description
Abstraction over a block header for a substrate chain.
Fields
parent_hash: Hash::Output
The parent hash.
number: Number
The block number.
state_root: Hash::Output
The state trie merkle root
extrinsics_root: Hash::Output
The merkle root of the extrinsics.
digest: Digest<Hash::Output>
A chain-specific digest of data useful for light clients or referencing auxiliary data.
Implementations
sourceimpl<Number, Hash> Header<Number, Hash> where
Number: Member + Hash + Copy + MaybeDisplay + AtLeast32BitUnsigned + Codec + Into<U256> + TryFrom<U256>,
Hash: HashT,
Hash::Output: Default + Hash + Copy + Member + MaybeDisplay + SimpleBitOps + Codec,
impl<Number, Hash> Header<Number, Hash> where
Number: Member + Hash + Copy + MaybeDisplay + AtLeast32BitUnsigned + Codec + Into<U256> + TryFrom<U256>,
Hash: HashT,
Hash::Output: Default + Hash + Copy + Member + MaybeDisplay + SimpleBitOps + Codec,
sourceimpl Header<u64, BlakeTwo256>
impl Header<u64, BlakeTwo256>
sourcepub fn new_from_number(number: <Self as Header>::Number) -> Self
pub fn new_from_number(number: <Self as Header>::Number) -> Self
A new header with the given number and default hash for all other fields.
Trait Implementations
sourceimpl<Number: Clone + Copy + Into<U256> + TryFrom<U256>, Hash: Clone + HashT> Clone for Header<Number, Hash> where
Hash::Output: Clone,
Hash::Output: Clone,
Hash::Output: Clone,
Hash::Output: Clone,
impl<Number: Clone + Copy + Into<U256> + TryFrom<U256>, Hash: Clone + HashT> Clone for Header<Number, Hash> where
Hash::Output: Clone,
Hash::Output: Clone,
Hash::Output: Clone,
Hash::Output: Clone,
sourceimpl<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> Debug for Header<Number, Hash> where
Number: Debug,
Hash: Debug,
impl<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> Debug for Header<Number, Hash> where
Number: Debug,
Hash: Debug,
sourceimpl<Number, Hash> Decode for Header<Number, Hash> where
Number: HasCompact + Copy + Into<U256> + TryFrom<U256>,
Hash: HashT,
Hash::Output: Decode,
impl<Number, Hash> Decode for Header<Number, Hash> where
Number: HasCompact + Copy + Into<U256> + TryFrom<U256>,
Hash: HashT,
Hash::Output: Decode,
sourcefn decode<I: Input>(input: &mut I) -> Result<Self, Error>
fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
Attempt to deserialise the value from input.
sourcefn skip<I>(input: &mut I) -> Result<(), Error> where
I: Input,
fn skip<I>(input: &mut I) -> Result<(), Error> where
I: Input,
Attempt to skip the encoded value from input. Read more
sourcefn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type. Read more
sourceimpl<'de, Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> Deserialize<'de> for Header<Number, Hash> where
Hash::Output: Deserialize<'de>,
Hash::Output: Deserialize<'de>,
Hash::Output: Deserialize<'de>,
impl<'de, Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> Deserialize<'de> for Header<Number, Hash> where
Hash::Output: Deserialize<'de>,
Hash::Output: Deserialize<'de>,
Hash::Output: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<Number, Hash> Encode for Header<Number, Hash> where
Number: HasCompact + Copy + Into<U256> + TryFrom<U256>,
Hash: HashT,
Hash::Output: Encode,
impl<Number, Hash> Encode for Header<Number, Hash> where
Number: HasCompact + Copy + Into<U256> + TryFrom<U256>,
Hash: HashT,
Hash::Output: Encode,
sourcefn encode_to<T: Output + ?Sized>(&self, dest: &mut T)
fn encode_to<T: Output + ?Sized>(&self, dest: &mut T)
Convert self to a slice and append it to the destination.
sourcefn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
sourcefn encode(&self) -> Vec<u8, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn encode(&self) -> Vec<u8, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Convert self to an owned vector.
sourcefn using_encoded<R, F>(&self, f: F) -> R where
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> R where
F: FnOnce(&[u8]) -> R,
Convert self to a slice and then invoke the given closure with it.
sourcefn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
sourceimpl<Number, Hash> Header for Header<Number, Hash> where
Number: Member + MaybeSerializeDeserialize + Debug + Hash + MaybeDisplay + AtLeast32BitUnsigned + Codec + Copy + Into<U256> + TryFrom<U256> + FromStr + MaybeMallocSizeOf,
Hash: HashT,
Hash::Output: Default + Hash + Copy + Member + Ord + MaybeSerialize + Debug + MaybeDisplay + SimpleBitOps + Codec + MaybeMallocSizeOf,
impl<Number, Hash> Header for Header<Number, Hash> where
Number: Member + MaybeSerializeDeserialize + Debug + Hash + MaybeDisplay + AtLeast32BitUnsigned + Codec + Copy + Into<U256> + TryFrom<U256> + FromStr + MaybeMallocSizeOf,
Hash: HashT,
Hash::Output: Default + Hash + Copy + Member + Ord + MaybeSerialize + Debug + MaybeDisplay + SimpleBitOps + Codec + MaybeMallocSizeOf,
type Number = Number
type Number = Number
Header number.
type Hashing = Hash
type Hashing = Hash
Hashing algorithm
sourcefn set_number(&mut self, num: Self::Number)
fn set_number(&mut self, num: Self::Number)
Sets the header number.
sourcefn extrinsics_root(&self) -> &Self::Hash
fn extrinsics_root(&self) -> &Self::Hash
Returns a reference to the extrinsics root.
sourcefn set_extrinsics_root(&mut self, root: Self::Hash)
fn set_extrinsics_root(&mut self, root: Self::Hash)
Sets the extrinsic root.
sourcefn state_root(&self) -> &Self::Hash
fn state_root(&self) -> &Self::Hash
Returns a reference to the state root.
sourcefn set_state_root(&mut self, root: Self::Hash)
fn set_state_root(&mut self, root: Self::Hash)
Sets the state root.
sourcefn parent_hash(&self) -> &Self::Hash
fn parent_hash(&self) -> &Self::Hash
Returns a reference to the parent hash.
sourcefn set_parent_hash(&mut self, hash: Self::Hash)
fn set_parent_hash(&mut self, hash: Self::Hash)
Sets the parent hash.
sourcefn digest_mut(&mut self) -> &mut Digest<Self::Hash>
fn digest_mut(&mut self) -> &mut Digest<Self::Hash>
Get a mutable reference to the digest.
sourceimpl<Number, Hash> MallocSizeOf for Header<Number, Hash> where
Number: Copy + Into<U256> + TryFrom<U256> + MallocSizeOf,
Hash: HashT,
Hash::Output: MallocSizeOf,
impl<Number, Hash> MallocSizeOf for Header<Number, Hash> where
Number: Copy + Into<U256> + TryFrom<U256> + MallocSizeOf,
Hash: HashT,
Hash::Output: MallocSizeOf,
sourcefn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
If T::size_of
is a constant, consider implementing constant_size
as well. Read more
sourcefn constant_size() -> Option<usize>
fn constant_size() -> Option<usize>
Used to optimize MallocSizeOf
implementation for collections
like Vec
and HashMap
to avoid iterating over them unnecessarily.
The Self: Sized
bound is for object safety. Read more
sourceimpl<Number: PartialEq + Copy + Into<U256> + TryFrom<U256>, Hash: PartialEq + HashT> PartialEq<Header<Number, Hash>> for Header<Number, Hash> where
Hash::Output: PartialEq,
Hash::Output: PartialEq,
Hash::Output: PartialEq,
Hash::Output: PartialEq,
impl<Number: PartialEq + Copy + Into<U256> + TryFrom<U256>, Hash: PartialEq + HashT> PartialEq<Header<Number, Hash>> for Header<Number, Hash> where
Hash::Output: PartialEq,
Hash::Output: PartialEq,
Hash::Output: PartialEq,
Hash::Output: PartialEq,
sourceimpl<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> Serialize for Header<Number, Hash> where
Hash::Output: Serialize,
Hash::Output: Serialize,
Hash::Output: Serialize,
impl<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> Serialize for Header<Number, Hash> where
Hash::Output: Serialize,
Hash::Output: Serialize,
Hash::Output: Serialize,
impl<Number, Hash> EncodeLike<Header<Number, Hash>> for Header<Number, Hash> where
Number: HasCompact + Copy + Into<U256> + TryFrom<U256>,
Hash: HashT,
Hash::Output: Encode,
impl<Number: Eq + Copy + Into<U256> + TryFrom<U256>, Hash: Eq + HashT> Eq for Header<Number, Hash> where
Hash::Output: Eq,
Hash::Output: Eq,
Hash::Output: Eq,
Hash::Output: Eq,
impl<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> StructuralEq for Header<Number, Hash>
impl<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> StructuralPartialEq for Header<Number, Hash>
Auto Trait Implementations
impl<Number, Hash> RefUnwindSafe for Header<Number, Hash> where
Number: RefUnwindSafe,
<Hash as Hash>::Output: RefUnwindSafe,
impl<Number, Hash> Send for Header<Number, Hash> where
Number: Send,
impl<Number, Hash> Sync for Header<Number, Hash> where
Number: Sync,
impl<Number, Hash> Unpin for Header<Number, Hash> where
Number: Unpin,
<Hash as Hash>::Output: Unpin,
impl<Number, Hash> UnwindSafe for Header<Number, Hash> where
Number: UnwindSafe,
<Hash as Hash>::Output: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedConversion for T
impl<T> CheckedConversion for T
sourcefn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
Convert from a value of T
into an equivalent instance of Option<Self>
. Read more
sourcefn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
Consume self to return Some
equivalent value of Option<T>
. Read more
sourceimpl<T> DecodeLimit for T where
T: Decode,
impl<T> DecodeLimit for T where
T: Decode,
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<T> MallocSizeOfExt for T where
T: MallocSizeOf,
impl<T> MallocSizeOfExt for T where
T: MallocSizeOf,
sourcefn malloc_size_of(&self) -> usize
fn malloc_size_of(&self) -> usize
Method to launch a heapsize measurement with a fresh state. Read more
sourceimpl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
sourcefn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
Convert from a value of T
into an equivalent instance of Self
. Read more
sourcefn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of T
. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.
sourceimpl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
sourcepub fn unique_saturated_into(self) -> T
pub fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of T
.