pub struct ValidatorSet { /* private fields */ }Expand description
A set of validators authorized to produce blocks.
Implementations§
Source§impl ValidatorSet
impl ValidatorSet
Sourcepub fn leader_for_round(&self, round: u64) -> Option<&SealerId>
pub fn leader_for_round(&self, round: u64) -> Option<&SealerId>
Get the leader for a given round (round-robin).
Returns None if the set is empty.
Sourcepub fn leader_for_height(&self, height: u64) -> Option<&SealerId>
pub fn leader_for_height(&self, height: u64) -> Option<&SealerId>
Get the leader for a given block height.
This is the same as leader_for_round but more semantically clear
when used in block production context.
Sourcepub fn validators(&self) -> &[SealerId]
pub fn validators(&self) -> &[SealerId]
Get all validators.
Sourcepub fn add(&mut self, validator: SealerId) -> bool
pub fn add(&mut self, validator: SealerId) -> bool
Add a validator to the set.
Returns true if the validator was added, false if already present.
Sourcepub fn remove(&mut self, validator: &SealerId) -> bool
pub fn remove(&mut self, validator: &SealerId) -> bool
Remove a validator from the set.
Returns true if the validator was removed, false if not present.
Sourcepub fn commitment(&self) -> Hash
pub fn commitment(&self) -> Hash
Compute a commitment hash of the validator set.
This can be included in block headers for validator set verification.
Sourcepub fn has_supermajority_of(&self, other: &ValidatorSet) -> bool
pub fn has_supermajority_of(&self, other: &ValidatorSet) -> bool
Check if this validator set has supermajority (2/3+) of another set.
Used for validator set transitions.
Sourcepub fn supermajority_threshold(&self) -> usize
pub fn supermajority_threshold(&self) -> usize
Get the threshold for supermajority (2/3 + 1).
Sourcepub fn majority_threshold(&self) -> usize
pub fn majority_threshold(&self) -> usize
Get the threshold for simple majority (1/2 + 1).
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 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>,
impl Eq for ValidatorSet
Source§impl Hash for ValidatorSet
impl Hash for ValidatorSet
Source§impl PartialEq for ValidatorSet
impl PartialEq 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> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.