Trait sp_runtime::traits::Header
source · pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + TypeInfo + 'static {
type Number: Member + MaybeSerializeDeserialize + MaybeFromStr + Debug + Hash + Copy + MaybeDisplay + AtLeast32BitUnsigned + Default + TypeInfo + MaxEncodedLen + FullCodec;
type Hash: HashOutput;
type Hashing: Hash<Output = Self::Hash>;
// Required methods
fn new(
number: Self::Number,
extrinsics_root: Self::Hash,
state_root: Self::Hash,
parent_hash: Self::Hash,
digest: Digest
) -> Self;
fn number(&self) -> &Self::Number;
fn set_number(&mut self, number: Self::Number);
fn extrinsics_root(&self) -> &Self::Hash;
fn set_extrinsics_root(&mut self, root: Self::Hash);
fn state_root(&self) -> &Self::Hash;
fn set_state_root(&mut self, root: Self::Hash);
fn parent_hash(&self) -> &Self::Hash;
fn set_parent_hash(&mut self, hash: Self::Hash);
fn digest(&self) -> &Digest;
fn digest_mut(&mut self) -> &mut Digest;
// Provided method
fn hash(&self) -> Self::Hash { ... }
}
Expand description
Something which fulfills the abstract idea of a Substrate header. It has types for a Number
,
a Hash
and a Hashing
. It provides access to an extrinsics_root
, state_root
and
parent_hash
, as well as a digest
and a block number
.
You can also create a new
one from those fields.
Required Associated Types§
sourcetype Number: Member + MaybeSerializeDeserialize + MaybeFromStr + Debug + Hash + Copy + MaybeDisplay + AtLeast32BitUnsigned + Default + TypeInfo + MaxEncodedLen + FullCodec
type Number: Member + MaybeSerializeDeserialize + MaybeFromStr + Debug + Hash + Copy + MaybeDisplay + AtLeast32BitUnsigned + Default + TypeInfo + MaxEncodedLen + FullCodec
Header number.
sourcetype Hash: HashOutput
type Hash: HashOutput
Header hash type
Required Methods§
sourcefn new(
number: Self::Number,
extrinsics_root: Self::Hash,
state_root: Self::Hash,
parent_hash: Self::Hash,
digest: Digest
) -> Self
fn new( number: Self::Number, extrinsics_root: Self::Hash, state_root: Self::Hash, parent_hash: Self::Hash, digest: Digest ) -> Self
Creates new header.
sourcefn set_number(&mut self, number: Self::Number)
fn set_number(&mut self, number: 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
fn digest_mut(&mut self) -> &mut Digest
Get a mutable reference to the digest.