pub trait DeciderConfig: Sync + Send + 'static {
    // Required methods
    fn generate_proposal(&self) -> Bytes;
    fn verify_proposal(&self, prop: &[u8]) -> bool;
    fn sync_core<'life0, 'life1, 'async_trait>(
        &'life0 self,
        core: &'life1 mut Core
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn vote_weights(&self) -> BTreeMap<Ed25519PK, u64>;
    fn seed(&self) -> u128;
    fn my_secret(&self) -> Ed25519SK;
}
Expand description

Decider is a particular configuration that the consensus protocol must implement.

Using a trait instead of a struct improves ergonomics of the “callbacks”, as well as “polluting” the Decider with a generic bound that prevents confusion between Decider instances deciding different sorts of facts.

Required Methods§

source

fn generate_proposal(&self) -> Bytes

Generates a new proposal.

source

fn verify_proposal(&self, prop: &[u8]) -> bool

Returns whether a proposed decision is valid.

source

fn sync_core<'life0, 'life1, 'async_trait>( &'life0 self, core: &'life1 mut Core ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Synchronizes, in a best-effort fashion, this “Core” state with other players on the network. Should never return and be cancel-safe; the Decider itself will timeout this as needed.

source

fn vote_weights(&self) -> BTreeMap<Ed25519PK, u64>

Returns a mapping of each player’s public key to how many votes the player has. Must return the same value every time!

source

fn seed(&self) -> u128

Returns a random seed. Must return the same value every time!

source

fn my_secret(&self) -> Ed25519SK

Returns our secret key.

Implementors§