Skip to main content

Membership

Trait Membership 

Source
pub trait Membership<T: NodeType>:
    Debug
    + Send
    + Sync {
    type Error: Error + Send + Sync + 'static;
    type Snapshot: MembershipSnapshot<T, Error = Self::Error>;

    // Required methods
    fn snapshot(&self, epoch: EpochNumber) -> Option<Self::Snapshot>;
    fn genesis_stake_tables(&self) -> Arc<GenesisStakeTables<T>> ⓘ;
    fn first_epoch(&self) -> EpochNumber;
    fn highest_known_epoch(&self) -> Option<EpochNumber>;
    fn get_epoch_root(
        &self,
        e: EpochNumber,
        coordinator: &EpochMembershipCoordinator<T>,
    ) -> impl Future<Output = Result<Leaf2<T>, Self::Error>> + Send;
    fn get_epoch_drb(
        &self,
        e: EpochNumber,
        coordinator: &EpochMembershipCoordinator<T>,
    ) -> impl Future<Output = Result<DrbResult, Self::Error>> + Send;
    fn add_epoch_root(
        &self,
        h: T::BlockHeader,
        coordinator: &EpochMembershipCoordinator<T>,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn add_drb_result(&self, e: EpochNumber, d: DrbResult);
    fn load_stake_table(
        &self,
        epoch: EpochNumber,
    ) -> impl Future<Output = bool> + Send;
    fn add_da_committee(
        &self,
        first_epoch: EpochNumber,
        da_committee: Vec<PeerConfig<T>>,
    );
}
Expand description

A protocol for determining membership in and participating in a committee.

Per-epoch reads go through Self::snapshot, and reads of the views before the first epoch through Self::genesis_stake_tables.

Each snapshot is a consistent point-in-time view; derived values read from the same snapshot are guaranteed to come from one logical moment.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Source

type Snapshot: MembershipSnapshot<T, Error = Self::Error>

A consistent per-epoch view, returned by Self::snapshot.

Required Methods§

Source

fn snapshot(&self, epoch: EpochNumber) -> Option<Self::Snapshot>

Capture a consistent per-epoch view.

Returns None if no committee is loaded for epoch.

Source

fn genesis_stake_tables(&self) -> Arc<GenesisStakeTables<T>> ⓘ

The stake tables of views before the first epoch.

Source

fn first_epoch(&self) -> EpochNumber

The first epoch, which runs on the genesis stake table.

Source

fn highest_known_epoch(&self) -> Option<EpochNumber>

Get the highest epoch for which a stake table is currently in memory, or None if no stake tables are loaded. It is where catchup resumes from, so an implementation that leaves it at None makes catchup rediscover that point one epoch at a time.

Source

fn get_epoch_root( &self, e: EpochNumber, coordinator: &EpochMembershipCoordinator<T>, ) -> impl Future<Output = Result<Leaf2<T>, Self::Error>> + Send

Gets the validated block header and epoch number of the epoch root at the given block height.

Source

fn get_epoch_drb( &self, e: EpochNumber, coordinator: &EpochMembershipCoordinator<T>, ) -> impl Future<Output = Result<DrbResult, Self::Error>> + Send

Gets the DRB result for the given epoch.

Source

fn add_epoch_root( &self, h: T::BlockHeader, coordinator: &EpochMembershipCoordinator<T>, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Handles notifications that a new epoch root has been created.

Source

fn add_drb_result(&self, e: EpochNumber, d: DrbResult)

Called to notify the Membership when a new DRB result has been calculated.

Source

fn load_stake_table( &self, epoch: EpochNumber, ) -> impl Future<Output = bool> + Send

Load the committee for epoch from local storage.

Returns true if a snapshot for epoch is available afterwards.

Source

fn add_da_committee( &self, first_epoch: EpochNumber, da_committee: Vec<PeerConfig<T>>, )

Register a DA committee that takes effect starting at first_epoch.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§