pub struct ValidatorSet { /* private fields */ }Expand description
The validator set for a given epoch.
Implementations§
Source§impl ValidatorSet
impl ValidatorSet
Sourcepub fn new(
validators: Vec<Validator>,
epoch: u64,
config: ValidatorConfig,
) -> Result<Self>
pub fn new( validators: Vec<Validator>, epoch: u64, config: ValidatorConfig, ) -> Result<Self>
Creates a new validator set.
Sourcepub fn validators(&self) -> &[Validator]
pub fn validators(&self) -> &[Validator]
Returns all validators.
Sourcepub fn active_validators(&self) -> Vec<&Validator>
pub fn active_validators(&self) -> Vec<&Validator>
Returns all active validators.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Returns the number of active validators.
Sourcepub fn get(&self, pubkey: &SerializablePublicKey) -> Option<&Validator>
pub fn get(&self, pubkey: &SerializablePublicKey) -> Option<&Validator>
Gets a validator by public key.
Sourcepub fn is_validator(&self, pubkey: &SerializablePublicKey) -> bool
pub fn is_validator(&self, pubkey: &SerializablePublicKey) -> bool
Checks if a public key belongs to a validator.
Sourcepub fn is_active_validator(&self, pubkey: &SerializablePublicKey) -> bool
pub fn is_active_validator(&self, pubkey: &SerializablePublicKey) -> bool
Checks if a public key belongs to an active validator.
Sourcepub fn total_weight(&self) -> u64
pub fn total_weight(&self) -> u64
Returns the total voting weight.
Sourcepub fn active_weight(&self) -> u64
pub fn active_weight(&self) -> u64
Returns the total active voting weight.
Sourcepub fn quorum_weight(&self) -> u64
pub fn quorum_weight(&self) -> u64
Returns the quorum weight required for consensus.
Sourcepub fn max_byzantine_weight(&self) -> u64
pub fn max_byzantine_weight(&self) -> u64
Returns the maximum Byzantine weight that can be tolerated. For f < n/3, this is floor((n-1)/3).
Sourcepub fn leader_for_view(&self, view: u64) -> Option<&Validator>
pub fn leader_for_view(&self, view: u64) -> Option<&Validator>
Gets the leader for a given view using round-robin selection.
Sourcepub fn leader_index_for_view(&self, view: u64) -> Option<usize>
pub fn leader_index_for_view(&self, view: u64) -> Option<usize>
Gets the leader index for a given view.
Sourcepub fn block_time_ms(&self) -> u64
pub fn block_time_ms(&self) -> u64
Returns the target block time.
Sourcepub fn config(&self) -> &ValidatorConfig
pub fn config(&self) -> &ValidatorConfig
Returns the configuration.
Sourcepub fn has_quorum(&self, signers: &[SerializablePublicKey]) -> bool
pub fn has_quorum(&self, signers: &[SerializablePublicKey]) -> bool
Checks if a set of signers meets quorum.
Sourcepub fn active_addresses(&self) -> Vec<SocketAddr>
pub fn active_addresses(&self) -> Vec<SocketAddr>
Gets the network addresses of all active validators.
Sourcepub fn active_pubkeys(&self) -> Vec<SerializablePublicKey>
pub fn active_pubkeys(&self) -> Vec<SerializablePublicKey>
Gets the public keys of all active validators.
Trait Implementations§
Source§impl Clone for ValidatorSet
impl Clone for ValidatorSet
Source§fn clone(&self) -> ValidatorSet
fn clone(&self) -> ValidatorSet
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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>,
Auto Trait Implementations§
impl Freeze for ValidatorSet
impl RefUnwindSafe for ValidatorSet
impl Send for ValidatorSet
impl Sync for ValidatorSet
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more