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:
Self::snapshotfor per-epoch readsSelf::non_epoch_snapshotfor pre-epoch reads
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.
Sourcetype NonEpochSnapshot: NonEpochMembershipSnapshot<T, Error = Self::Error>
type NonEpochSnapshot: NonEpochMembershipSnapshot<T, Error = Self::Error>
A consistent pre-epoch view, returned by Self::non_epoch_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 non_epoch_snapshot(&self) -> Self::NonEpochSnapshot
fn non_epoch_snapshot(&self) -> Self::NonEpochSnapshot
Capture a consistent pre-epoch view.
Sourcefn first_epoch(&self) -> Option<EpochNumber>
fn first_epoch(&self) -> Option<EpochNumber>
Get first epoch if epochs are enabled, None otherwise.
Sourcefn get_epoch_root(
&self,
e: EpochNumber,
) -> impl Future<Output = Result<Leaf2<T>, Self::Error>> + Send
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.
Sourcefn get_epoch_drb(
&self,
e: EpochNumber,
) -> impl Future<Output = Result<DrbResult, Self::Error>> + Send
fn get_epoch_drb( &self, e: EpochNumber, ) -> impl Future<Output = Result<DrbResult, Self::Error>> + Send
Gets the DRB result for the given epoch.
Sourcefn add_epoch_root(
&self,
h: T::BlockHeader,
) -> impl Future<Output = Result<(), Self::Error>> + Send
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.
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 set_first_epoch(&self, e: EpochNumber, r: DrbResult)
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.
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.
Provided Methods§
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. 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.