Skip to main content

Block

Trait Block 

Source
pub trait Block:
    Clone
    + Send
    + Sync
    + Codec
    + Eq
    + MaybeSerialize
    + Debug
    + MaybeMallocSizeOf
    + 'static {
    type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize + MaybeMallocSizeOf;
    type Header: Header<Hash = Self::Hash> + MaybeMallocSizeOf;
    type Hash: Member + MaybeSerializeDeserialize + Debug + Hash + Ord + Copy + MaybeDisplay + Default + SimpleBitOps + Codec + AsRef<[u8]> + AsMut<[u8]> + MaybeMallocSizeOf;

    // 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;
    fn encode_from(
        header: &Self::Header,
        extrinsics: &[Self::Extrinsic],
    ) -> Vec<u8> ;

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

Something which fulfills the abstract idea of a Tetcore 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§

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.

Source

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

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

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 tp_runtime::generic::Block<Header, Extrinsic>
where Header: HeaderT, Extrinsic: Member + Codec + Extrinsic + MaybeMallocSizeOf + MaybeSerialize,

Source§

type Extrinsic = Extrinsic

Source§

type Header = Header

Source§

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

Source§

impl<Xt: 'static + Codec + Sized + Send + Sync + Serialize + Clone + Eq + Debug + Extrinsic> Block for tp_runtime::testing::Block<Xt>