Skip to main content

Block

Trait Block 

Source
pub trait Block:
    HeaderProvider<HeaderT = Self::Header>
    + Into<Self::LazyBlock>
    + EncodeLike<Self::LazyBlock>
    + Clone
    + Send
    + Sync
    + Codec
    + DecodeWithMemTracking
    + Eq
    + MaybeSerialize
    + Debug
    + 'static {
    type Extrinsic: Member + Codec + ExtrinsicLike + MaybeSerialize + Into<OpaqueExtrinsic>;
    type Header: Header<Hash = Self::Hash> + MaybeSerializeDeserialize;
    type Hash: HashOutput;
    type LazyBlock: LazyBlock<Extrinsic = Self::Extrinsic, Header = Self::Header> + EncodeLike<Self>;

    // Required methods
    fn header(&self) -> &Self::Header;
    fn extrinsics(&self) -> &[Self::Extrinsic];
    fn deconstruct(self) -> (Self::Header, Vec<Self::Extrinsic>);
    fn new(header: Self::Header, extrinsics: Vec<Self::Extrinsic>) -> Self;

    // Provided method
    fn hash(&self) -> Self::Hash { ... }
}
Expand description

Something which fulfills the abstract idea of a Substrate block. It has types for Extrinsic pieces of information as well as a Header.

You can get an iterator over each of the extrinsics and retrieve the header.

Required Associated Types§

Source

type Extrinsic: Member + Codec + ExtrinsicLike + MaybeSerialize + Into<OpaqueExtrinsic>

Type for extrinsics.

Source

type Header: Header<Hash = Self::Hash> + MaybeSerializeDeserialize

Header type.

Source

type Hash: HashOutput

Block hash type.

Source

type LazyBlock: LazyBlock<Extrinsic = Self::Extrinsic, Header = Self::Header> + EncodeLike<Self>

A shadow structure which allows us to lazily decode the extrinsics. The LazyBlock must have the same encoded representation as the Block.

Required Methods§

Source

fn header(&self) -> &Self::Header

Returns a reference to the header.

Source

fn extrinsics(&self) -> &[Self::Extrinsic]

Returns a reference to the list of extrinsics.

Source

fn deconstruct(self) -> (Self::Header, Vec<Self::Extrinsic>)

Split the block into header and list of extrinsics.

Source

fn new(header: Self::Header, extrinsics: Vec<Self::Extrinsic>) -> Self

Creates new block from header and extrinsics.

Provided Methods§

Source

fn hash(&self) -> Self::Hash

Returns the hash of the block.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<Header, Extrinsic> Block for sp_runtime::generic::Block<Header, Extrinsic>

Source§

type Extrinsic = Extrinsic

Source§

type Header = Header

Source§

type Hash = <<Block<Header, Extrinsic> as Block>::Header as Header>::Hash

Source§

type LazyBlock = LazyBlock<Header, Extrinsic>

Source§

impl<Xt: 'static + Codec + DecodeWithMemTracking + Sized + Send + Sync + Serialize + Clone + Eq + Debug + ExtrinsicLike + Into<OpaqueExtrinsic> + LazyExtrinsic> Block for sp_runtime::testing::Block<Xt>