Trait LeaderSelection

pub trait LeaderSelection {
    type Block: Block;
    type Error: Error;
    type LeaderId: LeaderId;
    type State: State;

    // Required methods
    fn retrieve(state: &Self::State) -> Self;
    fn get_leader_at(
        &self,
        date: <Self::Block as Block>::Date,
    ) -> Result<Self::LeaderId, Self::Error>;
}
Expand description

interface for the leader selection algorithm

this is the interface that is responsible to verify the Block are created by the right Leaders (i.e. that everyone follows the consensus algorithm).

This is also the same interface that is used to detect if we are the leader for the block at the given date.

Required Associated Types§

type Block: Block

the block that we will get the information from

type Error: Error

Leader Selection error type

type LeaderId: LeaderId

Identifier of the leader (e.g. a public key).

type State: State

Required Methods§

fn retrieve(state: &Self::State) -> Self

fn get_leader_at( &self, date: <Self::Block as Block>::Date, ) -> Result<Self::LeaderId, Self::Error>

return the ID of the leader of the blockchain at the given date.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§