pub struct ValidatorSet {
pub epoch: u64,
pub epoch_start: Timestamp,
/* private fields */
}Expand description
A set of validators for an epoch
Fields§
§epoch: u64Current epoch number
epoch_start: TimestampEpoch start timestamp
Implementations§
Source§impl ValidatorSet
impl ValidatorSet
Sourcepub fn new(epoch: u64, validators: Vec<ValidatorInfo>) -> Result<Self>
pub fn new(epoch: u64, validators: Vec<ValidatorInfo>) -> Result<Self>
Creates a new validator set for the given epoch
Sourcepub fn get(&self, index: usize) -> Option<&ValidatorInfo>
pub fn get(&self, index: usize) -> Option<&ValidatorInfo>
Returns the validator at the given index
Sourcepub fn get_by_address(&self, address: &Address) -> Option<&ValidatorInfo>
pub fn get_by_address(&self, address: &Address) -> Option<&ValidatorInfo>
Returns the validator with the given address
Sourcepub fn index_of(&self, address: &Address) -> Option<usize>
pub fn index_of(&self, address: &Address) -> Option<usize>
Returns the position of a validator in self.validators matching the
given address, or None if not present.
This is the canonical “validator index” used for bitmap-based BLS
signer encoding in crate::voter::QuorumCertificate::signer_bitmap.
The index is stable for the lifetime of the validator set (i.e. the
duration of one epoch); a new epoch may renumber.
Sourcepub fn active_validators(&self) -> &[ValidatorInfo]
pub fn active_validators(&self) -> &[ValidatorInfo]
Returns the validators slice in canonical order (insertion / epoch
order). The position of each entry in this slice is the bit index used
by crate::voter::QuorumCertificate::signer_bitmap when verifying
the BLS aggregate.
Sourcepub fn iter(&self) -> Iter<'_, ValidatorInfo>
pub fn iter(&self) -> Iter<'_, ValidatorInfo>
Returns an iterator over the validators
Sourcepub fn total_stake(&self) -> u128
pub fn total_stake(&self) -> u128
Returns the total stake
Sourcepub fn total_voting_power(&self) -> u128
pub fn total_voting_power(&self) -> u128
Returns the total voting power (sum of active validators’ stake)
Sourcepub fn is_validator(&self, address: &Address) -> bool
pub fn is_validator(&self, address: &Address) -> bool
Returns whether the given address is a validator
Sourcepub fn select_leader_round_robin(&self, view: u64) -> Result<&ValidatorInfo>
pub fn select_leader_round_robin(&self, view: u64) -> Result<&ValidatorInfo>
Selects the leader for the given view via deterministic round-robin.
This is the simplest possible proposer election: view % N. It is
retained as a fallback / test path; production deployments should use
ReputationProposer via ProposerElection which incorporates
observed-behaviour reputation and a stake-weighted draw.
Sourcepub fn quorum_threshold(&self) -> usize
pub fn quorum_threshold(&self) -> usize
Calculates the quorum threshold (2f+1)
Sourcepub fn tee_attested_validators(&self) -> Vec<&ValidatorInfo>
pub fn tee_attested_validators(&self) -> Vec<&ValidatorInfo>
Returns the validators with valid TEE attestation
Sourcepub fn tee_attestation_rate(&self) -> f64
pub fn tee_attestation_rate(&self) -> f64
Returns the percentage of validators with TEE attestation
Trait Implementations§
Source§impl Clone for ValidatorSet
impl Clone for ValidatorSet
Source§fn clone(&self) -> ValidatorSet
fn clone(&self) -> ValidatorSet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more