Trait hotshot_types::traits::election::Membership
source · pub trait Membership<TYPES: NodeType>:
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§
Required Methods§
sourcefn new(
stake_committee_members: Vec<PeerConfig<TYPES::SignatureKey>>,
da_committee_members: Vec<PeerConfig<TYPES::SignatureKey>>,
) -> Self
fn new( stake_committee_members: Vec<PeerConfig<TYPES::SignatureKey>>, da_committee_members: Vec<PeerConfig<TYPES::SignatureKey>>, ) -> Self
Create a committee
sourcefn stake_table(
&self,
epoch: TYPES::Epoch,
) -> Vec<<TYPES::SignatureKey as SignatureKey>::StakeTableEntry>
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
sourcefn da_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>
Get all participants in the committee (including their stake) for a specific epoch
sourcefn committee_members(
&self,
view_number: TYPES::View,
epoch: TYPES::Epoch,
) -> BTreeSet<TYPES::SignatureKey>
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
sourcefn da_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>
Get all participants in the committee for a specific view for a specific epoch
sourcefn committee_leaders(
&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>
Get all leaders in the committee for a specific view for a specific epoch
sourcefn stake(
&self,
pub_key: &TYPES::SignatureKey,
epoch: TYPES::Epoch,
) -> Option<<TYPES::SignatureKey as SignatureKey>::StakeTableEntry>
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
sourcefn da_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>
Get the DA stake table entry for a public key, returns None
if the
key is not in the table for a specific epoch
sourcefn has_stake(&self, pub_key: &TYPES::SignatureKey, epoch: TYPES::Epoch) -> bool
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
sourcefn has_da_stake(
&self,
pub_key: &TYPES::SignatureKey,
epoch: TYPES::Epoch,
) -> bool
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
sourcefn lookup_leader(
&self,
view: TYPES::View,
epoch: TYPES::Epoch,
) -> Result<TYPES::SignatureKey, Self::Error>
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
sourcefn total_nodes(&self, epoch: TYPES::Epoch) -> usize
fn total_nodes(&self, epoch: TYPES::Epoch) -> usize
Returns the number of total nodes in the committee in an epoch epoch
sourcefn da_total_nodes(&self, epoch: TYPES::Epoch) -> usize
fn da_total_nodes(&self, epoch: TYPES::Epoch) -> usize
Returns the number of total DA nodes in the committee in an epoch epoch
sourcefn success_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64
fn success_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64
Returns the threshold for a specific Membership
implementation
sourcefn da_success_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64
fn da_success_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64
Returns the DA threshold for a specific Membership
implementation
sourcefn failure_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64
fn failure_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64
Returns the threshold for a specific Membership
implementation
sourcefn upgrade_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64
fn upgrade_threshold(&self, epoch: TYPES::Epoch) -> NonZeroU64
Returns the threshold required to upgrade the network protocol
Provided Methods§
sourcefn leader(
&self,
view: TYPES::View,
epoch: TYPES::Epoch,
) -> Result<TYPES::SignatureKey>
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.