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>;
    type NonEpochSnapshot: NonEpochMembershipSnapshot<T, Error = Self::Error>;

    // Required methods
    fn snapshot(&self, epoch: EpochNumber) -> Option<Self::Snapshot>;
    fn non_epoch_snapshot(&self) -> Self::NonEpochSnapshot;
    fn first_epoch(&self) -> Option<EpochNumber>;
    fn get_epoch_root(
        &self,
        e: EpochNumber,
    ) -> impl Future<Output = Result<Leaf2<T>, Self::Error>> + Send;
    fn get_epoch_drb(
        &self,
        e: EpochNumber,
    ) -> impl Future<Output = Result<DrbResult, Self::Error>> + Send;
    fn add_epoch_root(
        &self,
        h: T::BlockHeader,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn add_drb_result(&self, e: EpochNumber, d: DrbResult);
    fn set_first_epoch(&self, e: EpochNumber, r: DrbResult);
    fn add_da_committee(
        &self,
        first_epoch: EpochNumber,
        da_committee: Vec<PeerConfig<T>>,
    );

    // Provided method
    fn highest_known_epoch(&self) -> Option<EpochNumber> { ... }
}
Expand description

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

All read access goes through one of two snapshot types:

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.

Source

type NonEpochSnapshot: NonEpochMembershipSnapshot<T, Error = Self::Error>

A consistent pre-epoch view, returned by Self::non_epoch_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 non_epoch_snapshot(&self) -> Self::NonEpochSnapshot

Capture a consistent pre-epoch view.

Source

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

Get first epoch if epochs are enabled, None otherwise.

Source

fn get_epoch_root( &self, e: EpochNumber, ) -> 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, ) -> 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, ) -> 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 set_first_epoch(&self, e: EpochNumber, r: DrbResult)

Called to notify the Membership that Epochs are enabled. Implementations should copy the pre-epoch stake table into epoch and epoch+1 when this is called. The value of initial_drb_result should be used for DRB calculations for epochs (epoch+1) and earlier.

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.

Provided Methods§

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. Used at startup to find the point from which to walk forward catching up missing epochs.

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§