pub struct View(/* private fields */);Expand description
A monotonically increasing counter within a single epoch.
Views represent individual consensus rounds within an epoch. Each view corresponds to one attempt to reach consensus on a proposal.
Implementations§
Source§impl View
impl View
Sourcepub const fn next(self) -> Self
pub const fn next(self) -> Self
Returns the next view.
§Panics
Panics if the view would overflow u64::MAX. In practice, this is extremely unlikely to occur during normal operation.
Sourcepub fn previous(self) -> Option<Self>
pub fn previous(self) -> Option<Self>
Returns the previous view, or None if this is view zero.
Unlike View::next(), this returns an Option since reaching view zero
is common, whereas overflowing u64::MAX is not expected in normal
operation.
Sourcepub const fn saturating_add(self, delta: ViewDelta) -> Self
pub const fn saturating_add(self, delta: ViewDelta) -> Self
Adds a view delta, saturating at u64::MAX.
Sourcepub const fn saturating_sub(self, delta: ViewDelta) -> Self
pub const fn saturating_sub(self, delta: ViewDelta) -> Self
Subtracts a view delta, saturating at zero.
Sourcepub const fn range(start: Self, end: Self) -> ViewRange ⓘ
pub const fn range(start: Self, end: Self) -> ViewRange ⓘ
Returns an iterator over the range [start, end).
If start >= end, returns an empty range.
Sourcepub const fn term_start(self, term_length: TermLength) -> Self
pub const fn term_start(self, term_length: TermLength) -> Self
Returns the first view of the term containing this view.
Terms group consecutive views so that the same leader serves for
term_length views. View 0 (genesis) is its own term. For views >= 1,
term boundaries are: [1, term_length], [term_length+1, 2*term_length], …
When term_length is 1, every view is its own term (no grouping).
Sourcepub const fn is_term_start(self, term_length: TermLength) -> bool
pub const fn is_term_start(self, term_length: TermLength) -> bool
Returns whether this view is the first view of its term.
Sourcepub const fn same_term(self, other: Self, term_length: TermLength) -> bool
pub const fn same_term(self, other: Self, term_length: TermLength) -> bool
Returns whether this view shares a term with other.
Sourcepub const fn term_end(self, term_length: TermLength) -> Self
pub const fn term_end(self, term_length: TermLength) -> Self
Returns the last view of the term containing this view.
See term_start for term boundary semantics.
When term_length is 1, returns self.
Sourcepub const fn next_term_start(self, term_length: TermLength) -> Self
pub const fn next_term_start(self, term_length: TermLength) -> Self
Returns the first view of the term that follows this view’s term.
When term_length is 1, returns self.next().
Sourcepub const fn term_index(self, term_length: TermLength) -> u64
pub const fn term_index(self, term_length: TermLength) -> u64
Returns the index of the term containing this view.
View 0 (genesis) is its own term with index 0; terms of later views
are numbered from 1. When term_length is 1, the index equals the
view.
Sourcepub const fn covers(self, view: Self, term_length: TermLength) -> bool
pub const fn covers(self, view: Self, term_length: TermLength) -> bool
Returns whether a nullification at this view covers view.
A nullification covers the view it was created for and the rest of that view’s term.
Sourcepub const fn covering_range(
self,
term_length: TermLength,
) -> RangeInclusive<Self> ⓘ
pub const fn covering_range( self, term_length: TermLength, ) -> RangeInclusive<Self> ⓘ
Returns the range of views whose nullifications cover this view.
The inverse of covers: a nullification covers the
rest of its term, so this view is covered by a nullification at any
view in [term_start, self].
Sourcepub const fn admits(self, pending: Self, term_length: TermLength) -> bool
pub const fn admits(self, pending: Self, term_length: TermLength) -> bool
Returns whether pending is an acceptable view relative to this view
when future views are bounded.
Views at or below this view are always acceptable (callers enforce any
lower bound separately). Beyond that, only the next view and the first
view of the next term are acceptable: the only views this view can
directly advance into (a nullification of the current view skips to
the latter). When term_length is 1 the two views are the same.
This bound exists to limit memory committed to unverified messages (like votes) from future views. It should not be applied to self-certifying artifacts (like certificates), which may arrive from arbitrarily far ahead and let a lagging participant fast-forward.
Trait Implementations§
impl Copy for View
Source§impl EncodeSize for View
impl EncodeSize for View
Source§fn encode_size(&self) -> usize
fn encode_size(&self) -> usize
Source§fn encode_inline_size(&self) -> usize
fn encode_inline_size(&self) -> usize
BufsMut::push
during Write::write_bufs. Used to size the working buffer for inline
writes. Override alongside Write::write_bufs for types where large
Bytes fields go via push; failing to do so will over-allocate.impl Eq for View
Source§impl Ord for View
impl Ord for View
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for View
impl PartialOrd for View
Source§impl Read for View
impl Read for View
impl StructuralPartialEq for View
Source§impl Write for View
impl Write for View
Source§fn write_bufs(&self, buf: &mut impl BufsMut)
fn write_bufs(&self, buf: &mut impl BufsMut)
BufsMut, allowing existing Bytes chunks to be
appended via BufsMut::push instead of written inline. Must encode
to the same format as Write::write. Defaults to Write::write.Auto Trait Implementations§
impl Freeze for View
impl RefUnwindSafe for View
impl Send for View
impl Sync for View
impl Unpin for View
impl UnsafeUnpin for View
impl UnwindSafe for View
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,
impl<T> Codec for T
Source§impl<T> Encode for Twhere
T: Write + EncodeSize,
impl<T> Encode for Twhere
T: Write + EncodeSize,
Source§impl<T> EncodeExt for Twhere
T: EncodeSize + Write,
impl<T> EncodeExt for Twhere
T: EncodeSize + Write,
Source§fn encode_with_pool_mut(&self, pool: &BufferPool) -> IoBufMut
fn encode_with_pool_mut(&self, pool: &BufferPool) -> IoBufMut
Source§fn encode_with_pool(&self, pool: &BufferPool) -> IoBufs
fn encode_with_pool(&self, pool: &BufferPool) -> IoBufs
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