pub struct ValidatorSet {
pub epoch: u64,
pub active_from: BlockHeight,
pub validators: Vec<ValidatorSetEntry>,
pub total_voting_power: Balance,
pub proposer_seed: [u8; 32],
}Expand description
The active validator set for an epoch
Fields§
§epoch: u64The epoch this validator set is for
active_from: BlockHeightBlock height when this set became active
validators: Vec<ValidatorSetEntry>List of validators sorted by voting power (descending)
total_voting_power: BalanceTotal voting power in this set
proposer_seed: [u8; 32]Proposer selection seed (hash of previous epoch’s last block)
Implementations§
Source§impl ValidatorSet
impl ValidatorSet
Sourcepub fn new(
epoch: u64,
active_from: BlockHeight,
validators: Vec<ValidatorSetEntry>,
proposer_seed: [u8; 32],
) -> Self
pub fn new( epoch: u64, active_from: BlockHeight, validators: Vec<ValidatorSetEntry>, proposer_seed: [u8; 32], ) -> Self
Create a new validator set
Sourcepub fn get(&self, pubkey: &[u8; 32]) -> Option<&ValidatorSetEntry>
pub fn get(&self, pubkey: &[u8; 32]) -> Option<&ValidatorSetEntry>
Get a validator’s entry by pubkey
Sourcepub fn get_stake_weighted_proposer(
&self,
height: BlockHeight,
) -> Option<[u8; 32]>
pub fn get_stake_weighted_proposer( &self, height: BlockHeight, ) -> Option<[u8; 32]>
Get the proposer for a given height using stake-weighted selection
Sourcepub fn get_round_robin_proposer(&self, height: BlockHeight) -> Option<[u8; 32]>
pub fn get_round_robin_proposer(&self, height: BlockHeight) -> Option<[u8; 32]>
Get the proposer for a given height using round-robin selection
Sourcepub fn voting_power(&self, pubkey: &[u8; 32]) -> Balance
pub fn voting_power(&self, pubkey: &[u8; 32]) -> Balance
Get the voting power for a validator
Sourcepub fn voting_power_percentage(&self, pubkey: &[u8; 32]) -> u16
pub fn voting_power_percentage(&self, pubkey: &[u8; 32]) -> u16
Calculate the voting power percentage for a validator (in basis points)
Trait Implementations§
Source§impl Clone for ValidatorSet
impl Clone for ValidatorSet
Source§fn clone(&self) -> ValidatorSet
fn clone(&self) -> ValidatorSet
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValidatorSet
impl Debug for ValidatorSet
Source§impl<'de> Deserialize<'de> for ValidatorSet
impl<'de> Deserialize<'de> for ValidatorSet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ValidatorSet
impl PartialEq for ValidatorSet
Source§fn eq(&self, other: &ValidatorSet) -> bool
fn eq(&self, other: &ValidatorSet) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for ValidatorSet
impl Serialize for ValidatorSet
impl Eq for ValidatorSet
impl StructuralPartialEq for ValidatorSet
Auto Trait Implementations§
impl Freeze for ValidatorSet
impl RefUnwindSafe for ValidatorSet
impl Send for ValidatorSet
impl Sync for ValidatorSet
impl Unpin for ValidatorSet
impl UnsafeUnpin for ValidatorSet
impl UnwindSafe for ValidatorSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more