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§
type Error: Error + Send + Sync + 'static
Sourcetype Snapshot: MembershipSnapshot<T, Error = Self::Error>
type Snapshot: MembershipSnapshot<T, Error = Self::Error>
A consistent per-epoch view, returned by Self::snapshot.
Required Methods§
Sourcefn snapshot(&self, epoch: EpochNumber) -> Option<Self::Snapshot>
fn snapshot(&self, epoch: EpochNumber) -> Option<Self::Snapshot>
Capture a consistent per-epoch view.
Returns None if no committee is loaded for epoch.
Sourcefn genesis_stake_tables(&self) -> Arc<GenesisStakeTables<T>> ⓘ
fn genesis_stake_tables(&self) -> Arc<GenesisStakeTables<T>> ⓘ
The stake tables of views before the first epoch.
Sourcefn first_epoch(&self) -> EpochNumber
fn first_epoch(&self) -> EpochNumber
The first epoch, which runs on the genesis stake table.
Sourcefn highest_known_epoch(&self) -> Option<EpochNumber>
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.
Sourcefn get_epoch_root(
&self,
e: EpochNumber,
coordinator: &EpochMembershipCoordinator<T>,
) -> impl Future<Output = Result<Leaf2<T>, Self::Error>> + Send
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.
Sourcefn get_epoch_drb(
&self,
e: EpochNumber,
coordinator: &EpochMembershipCoordinator<T>,
) -> impl Future<Output = Result<DrbResult, Self::Error>> + Send
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.
Sourcefn add_epoch_root(
&self,
h: T::BlockHeader,
coordinator: &EpochMembershipCoordinator<T>,
) -> impl Future<Output = Result<(), Self::Error>> + Send
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.
Sourcefn add_drb_result(&self, e: EpochNumber, d: DrbResult)
fn add_drb_result(&self, e: EpochNumber, d: DrbResult)
Called to notify the Membership when a new DRB result has been calculated.
Sourcefn load_stake_table(
&self,
epoch: EpochNumber,
) -> impl Future<Output = bool> + Send
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.
Sourcefn add_da_committee(
&self,
first_epoch: EpochNumber,
da_committee: Vec<PeerConfig<T>>,
)
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".