pub struct Random<H: Hasher = Sha256> { /* private fields */ }Expand description
Configuration for leader election using threshold signature randomness.
Uses the seed signature from BLS threshold certificates to derive unpredictable leader selection. Falls back to standard round-robin for view 1 when no certificate is available.
This elector does not support stable leaders: it has no term-length
configuration and Elector::terms always returns Terms::rotating.
Only works with super::scheme::bls12381_threshold::vrf
(implements super::scheme::bls12381_threshold::vrf::Seedable).
Implementations§
Source§impl<H: Hasher> Random<H>
impl<H: Hasher> Random<H>
Sourcepub const fn new(version: RandomVersion) -> Self
pub const fn new(version: RandomVersion) -> Self
Creates a configuration with the specified signature-to-leader mapping.
Sourcepub fn select_leader<V: Variant>(
&self,
round: Round,
n: u32,
seed_signature: Option<V::Signature>,
) -> Participant
pub fn select_leader<V: Variant>( &self, round: Round, n: u32, seed_signature: Option<V::Signature>, ) -> Participant
Returns the selected leader index for the given round and seed signature.
§Panics
Panics if n is zero, or if a seed signature is missing after view 1.
Trait Implementations§
Auto Trait Implementations§
impl<H> Freeze for Random<H>where
PhantomData<H>: Freeze,
impl<H> RefUnwindSafe for Random<H>where
PhantomData<H>: RefUnwindSafe,
impl<H> Send for Random<H>where
PhantomData<H>: Send,
impl<H> Sync for Random<H>where
PhantomData<H>: Sync,
impl<H> Unpin for Random<H>where
PhantomData<H>: Unpin,
impl<H> UnsafeUnpin for Random<H>where
PhantomData<H>: UnsafeUnpin,
impl<H> UnwindSafe for Random<H>where
PhantomData<H>: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
Converts
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> ⓘ
Converts
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