pub struct Terms { /* private fields */ }Expand description
Leadership term structure reported by an Elector.
Implementations§
Source§impl Terms
impl Terms
Sourcepub const fn rotating() -> Self
pub const fn rotating() -> Self
Every view is its own term: a new leader is elected each view, and leader rotation itself bounds how long finality can stall.
Sourcepub const fn stable(
length: TermLength,
stall_timeout: Duration,
optimistic_views: ViewDelta,
) -> Self
pub const fn stable( length: TermLength, stall_timeout: Duration, optimistic_views: ViewDelta, ) -> Self
Views are grouped into terms of length consecutive views served by
one leader.
The length is consensus-critical: every participant must configure
the same value (see TermLength).
stall_timeout is local policy: the maximum time an entered view may
remain unfinalized before this participant abandons the term. On
expiry it treats its current view as timed out and votes nullify,
which (with a quorum) forms a nullification covering the rest of the
term and evicts the leader.
A Byzantine stable leader can keep every per-view timer satisfied while preventing finality: each view notarizes and certifies, but no finalization certificate forms. With single-view terms, leader rotation bounds such a stall to one view. With longer terms, this timeout bounds it instead.
optimistic_views is how far a participant may optimistically run
ahead of certified ancestry within a term; zero disables optimistic
validation entirely, and values wider than length are accepted but
capped by the windows themselves. The voter tracks a round for every
optimistic view, so memory scales with the smaller of
optimistic_views and length. See Optimistic Validation for the
exact window, which anchors at the last directly notarized view. Like
the stall timeout, this is local policy: mismatched values across
participants only degrade the optimization, never safety.
§Panics
Panics if length is 1 or if stall_timeout is zero. Single-view
terms are Terms::rotating (the default), where per-view timeouts
already bound a stall and no optimistic window exists.
Sourcepub const fn length(&self) -> TermLength
pub const fn length(&self) -> TermLength
Returns the number of consecutive views per term.
Returns TermLength::ONE if and only if this is Terms::rotating.
A length of one is the definition of rotation, not an approximation of
it: all term arithmetic (View::covers, View::admits,
View::term_index, View::next_term_start) reduces exactly to
per-view behavior at length one. The only regime fact the length does
not carry is the stall deadline, which callers read from
Terms::stall_timeout.
Sourcepub const fn stall_timeout(&self) -> Option<Duration>
pub const fn stall_timeout(&self) -> Option<Duration>
Returns the term-abandonment timeout, if stable leaders are configured.
Returns Some if and only if Self::length is greater than one.
Sourcepub const fn optimistic_views(&self) -> ViewDelta
pub const fn optimistic_views(&self) -> ViewDelta
Returns the optimistic intra-term lookahead (see Terms::stable).
Always zero when Self::length is one.
Trait Implementations§
impl Copy for Terms
impl Eq for Terms
impl StructuralPartialEq for Terms
Auto Trait Implementations§
impl Freeze for Terms
impl RefUnwindSafe for Terms
impl Send for Terms
impl Sync for Terms
impl Unpin for Terms
impl UnsafeUnpin for Terms
impl UnwindSafe for Terms
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
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<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§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> ⓘ
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