pub trait BlockT: HeaderProvider<HeaderT = Self::Header> + Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static {
    type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize;
    type Header: Header<Hash = Self::Hash> + MaybeSerializeDeserialize;
    type Hash: HashOutput;

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

    // 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§

type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize

Type for extrinsics.

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

Header type.

type Hash: HashOutput

Block hash type.

Required Methods§

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

Returns a reference to the header.

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

Returns a reference to the list of extrinsics.

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

Split the block into header and list of extrinsics.

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

Creates new block from header and extrinsics.

fn encode_from( header: &Self::Header, extrinsics: &[Self::Extrinsic] ) -> Vec<u8, Global>

Creates an encoded block from the given header and extrinsics without requiring the creation of an instance.

Provided Methods§

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

Returns the hash of the block.

Implementors§

§

impl<Header, Extrinsic> Block for Block<Header, Extrinsic>where Extrinsic: MaybeSerialize + Member + Codec + Extrinsic, Header: Header + MaybeSerializeDeserialize,

§

type Extrinsic = Extrinsic

§

type Header = Header

§

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

§

impl<Xt> Block for Block<Xt>where Xt: 'static + Codec + Send + Sync + Serialize + Clone + Eq + Debug + Extrinsic,

§

type Extrinsic = Xt

§

type Header = Header<u64, BlakeTwo256>

§

type Hash = <Header<u64, BlakeTwo256> as Header>::Hash