Trait hotshot_types::traits::election::Membership

source ·
pub trait Membership<TYPES: NodeType>:
    Clone
    + Debug
    + Send
    + Sync {
    type Error: Display;

Show 18 methods // Required methods fn new( stake_committee_members: Vec<PeerConfig<TYPES::SignatureKey>>, da_committee_members: Vec<PeerConfig<TYPES::SignatureKey>>, ) -> Self; fn stake_table( &self, epoch: TYPES::Epoch, ) -> Vec<<TYPES::SignatureKey as SignatureKey>::StakeTableEntry>; fn da_stake_table( &self, epoch: TYPES::Epoch, ) -> Vec<<TYPES::SignatureKey as SignatureKey>::StakeTableEntry>; fn committee_members( &self, view_number: TYPES::View, epoch: TYPES::Epoch, ) -> BTreeSet<TYPES::SignatureKey>; fn da_committee_members( &self, view_number: TYPES::View, epoch: TYPES::Epoch, ) -> BTreeSet<TYPES::SignatureKey>; fn committee_leaders( &self, view_number: TYPES::View, epoch: TYPES::Epoch, ) -> BTreeSet<TYPES::SignatureKey>; fn stake( &self, pub_key: &TYPES::SignatureKey, epoch: TYPES::Epoch, ) -> Option<<TYPES::SignatureKey as SignatureKey>::StakeTableEntry>; fn da_stake( &self, pub_key: &TYPES::SignatureKey, epoch: TYPES::Epoch, ) -> Option<<TYPES::SignatureKey as SignatureKey>::StakeTableEntry>; fn has_stake( &self, pub_key: &TYPES::SignatureKey, epoch: TYPES::Epoch, ) -> bool; fn has_da_stake( &self, pub_key: &TYPES::SignatureKey, epoch: TYPES::Epoch, ) -> bool; fn lookup_leader( &self, view: TYPES::View, epoch: TYPES::Epoch, ) -> Result<TYPES::SignatureKey, Self::Error>; fn total_nodes(&self, epoch: TYPES::Epoch) -> usize; fn da_total_nodes(&self, epoch: TYPES::Epoch) -> usize; fn success_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64; fn da_success_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64; fn failure_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64; fn upgrade_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64; // Provided method fn leader( &self, view: TYPES::View, epoch: TYPES::Epoch, ) -> Result<TYPES::SignatureKey> { ... }
}
Expand description

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

Required Associated Types§

source

type Error: Display

The error type returned by methods like lookup_leader.

Required Methods§

source

fn new( stake_committee_members: Vec<PeerConfig<TYPES::SignatureKey>>, da_committee_members: Vec<PeerConfig<TYPES::SignatureKey>>, ) -> Self

Create a committee

source

fn stake_table( &self, epoch: TYPES::Epoch, ) -> Vec<<TYPES::SignatureKey as SignatureKey>::StakeTableEntry>

Get all participants in the committee (including their stake) for a specific epoch

source

fn da_stake_table( &self, epoch: TYPES::Epoch, ) -> Vec<<TYPES::SignatureKey as SignatureKey>::StakeTableEntry>

Get all participants in the committee (including their stake) for a specific epoch

source

fn committee_members( &self, view_number: TYPES::View, epoch: TYPES::Epoch, ) -> BTreeSet<TYPES::SignatureKey>

Get all participants in the committee for a specific view for a specific epoch

source

fn da_committee_members( &self, view_number: TYPES::View, epoch: TYPES::Epoch, ) -> BTreeSet<TYPES::SignatureKey>

Get all participants in the committee for a specific view for a specific epoch

source

fn committee_leaders( &self, view_number: TYPES::View, epoch: TYPES::Epoch, ) -> BTreeSet<TYPES::SignatureKey>

Get all leaders in the committee for a specific view for a specific epoch

source

fn stake( &self, pub_key: &TYPES::SignatureKey, epoch: TYPES::Epoch, ) -> Option<<TYPES::SignatureKey as SignatureKey>::StakeTableEntry>

Get the stake table entry for a public key, returns None if the key is not in the table for a specific epoch

source

fn da_stake( &self, pub_key: &TYPES::SignatureKey, epoch: TYPES::Epoch, ) -> Option<<TYPES::SignatureKey as SignatureKey>::StakeTableEntry>

Get the DA stake table entry for a public key, returns None if the key is not in the table for a specific epoch

source

fn has_stake(&self, pub_key: &TYPES::SignatureKey, epoch: TYPES::Epoch) -> bool

See if a node has stake in the committee in a specific epoch

source

fn has_da_stake( &self, pub_key: &TYPES::SignatureKey, epoch: TYPES::Epoch, ) -> bool

See if a node has stake in the committee in a specific epoch

source

fn lookup_leader( &self, view: TYPES::View, epoch: TYPES::Epoch, ) -> Result<TYPES::SignatureKey, Self::Error>

The leader of the committee for view view_number in epoch.

Note: There is no such thing as a DA leader, so any consumer requiring a leader should call this.

§Errors

Returns an error if the leader cannot be calculated

source

fn total_nodes(&self, epoch: TYPES::Epoch) -> usize

Returns the number of total nodes in the committee in an epoch epoch

source

fn da_total_nodes(&self, epoch: TYPES::Epoch) -> usize

Returns the number of total DA nodes in the committee in an epoch epoch

source

fn success_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64

Returns the threshold for a specific Membership implementation

source

fn da_success_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64

Returns the DA threshold for a specific Membership implementation

source

fn failure_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64

Returns the threshold for a specific Membership implementation

source

fn upgrade_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64

Returns the threshold required to upgrade the network protocol

Provided Methods§

source

fn leader( &self, view: TYPES::View, epoch: TYPES::Epoch, ) -> Result<TYPES::SignatureKey>

The leader of the committee for view view_number in epoch.

Note: this function uses a HotShot-internal error type. You should implement lookup_leader, rather than implementing this function directly.

§Errors

Returns an error if the leader cannot be calculated.

Object Safety§

This trait is not object safe.

Implementors§