Skip to main content

LoggedEpochConsensus

Struct LoggedEpochConsensus 

Source
pub struct LoggedEpochConsensus<V: Clone> { /* private fields */ }
Expand description

Abortable consensus within one epoch, whose acceptances survive a restart.

Implementations§

Source§

impl<V: Clone> LoggedEpochConsensus<V>

Source

pub fn new( me: NodeId, peers: impl IntoIterator<Item = NodeId>, ets: u64, leader: NodeId, state: State<V>, retransmit: Duration, ) -> Self

⟨ lep, Init | state ⟩ — an instance for epoch ets led by leader, beginning from state.

The book’s store(valts, val) in Init happens on the first event this instance handles, because a constructor has no context to write through. [Protocol::on_init] is where it lands, and it lands before anything is sent.

Source

pub fn timestamp(&self) -> u64

ets.

Source

pub fn is_aborted(&self) -> bool

Whether this instance has been abandoned.

Source

pub fn state(&self) -> &State<V>

(valts, val) — what this process has accepted.

Source

pub fn epoch_decision(&self) -> Option<&V>

epochdecision — what this epoch decided, if this process saw it decide.

Read by the layer above after a recovery: retrieve(epochdecision) of instance lep.ets is how Algorithm 5.10 learns that a process had decided before it went down.

Trait Implementations§

Source§

impl<V: Debug + Clone> Debug for LoggedEpochConsensus<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Clone> Protocol for LoggedEpochConsensus<V>

Source§

type Entry = Infallible

An epoch accepts at most one value and decides at most one. Nothing accumulates.

Source§

fn on_msg(&mut self, from: NodeId, msg: Wire<V>, cx: &mut ProtoCx<'_, Self>)

such that ts = ets, applied at the door.

Unlike crate::epoch_consensus, the link beneath keeps no duplicate set for a foreign message to poison — it deduplicates nothing at all. The guard is here for the safety reason alone: an acceptance recorded at the wrong timestamp is an acceptance that never happened.

Source§

fn on_init(&mut self, cx: &mut ProtoCx<'_, Self>)

upon event ⟨ lep, Init | state ⟩ do (valts, val) := state; store(valts, val); …

The state came in through the constructor; this is where it becomes durable, before this instance answers anything.

Source§

fn on_recovery(&mut self, cx: &mut ProtoCx<'_, Self>)

upon event ⟨ lep, Recovery ⟩ do retrieve(valts, val).

epochdecision comes back with it, because they share one metadata value. Nothing is re-indicated: a process that decided before it went down told the layer above at the time, and it is that layer’s own record — not a second Decide from here — that restores it. See LoggedEpochConsensus::epoch_decision.

Source§

type Cmd = Cmd<V>

Requests from the layer above.
Source§

type Ind = Ind<V>

Indications to the layer above — this protocol delivering on its guarantee.
Source§

type Msg = Wire<V>

What crosses the wire to a peer running the same protocol.
Source§

type Scope = Infallible

Scopes whose boundaries this protocol’s guarantees depend on, and which it can observe. Read more
Source§

type Note = Note

The vocabulary in which this protocol narrates its decisions. Read more
Source§

type Meta = Durable<V>

The durable value this protocol rewrites: a position, a count, an epoch. Small enough that rewriting it costs nothing. Read more
Source§

fn on_cmd(&mut self, cmd: Cmd<V>, cx: &mut ProtoCx<'_, Self>)

Handle a request from the layer above.
Source§

fn on_timer(&mut self, id: TimerId, cx: &mut ProtoCx<'_, Self>)

Handle a timer that fired somewhere in this protocol or in what it composes. Read more
§

fn on_scope_event( &mut self, _scope: Self::Scope, _cx: &mut Cx<'_, Self::Msg, Self::Ind, Self::Note, Self::Meta, Self::Entry>, )

Handle a boundary of a scope this protocol’s guarantees depend on — its end, or the beginning of the one that succeeds it. Read more

Auto Trait Implementations§

§

impl<V> Freeze for LoggedEpochConsensus<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for LoggedEpochConsensus<V>
where V: RefUnwindSafe,

§

impl<V> Send for LoggedEpochConsensus<V>
where V: Send,

§

impl<V> Sync for LoggedEpochConsensus<V>
where V: Sync,

§

impl<V> Unpin for LoggedEpochConsensus<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for LoggedEpochConsensus<V>
where V: UnsafeUnpin,

§

impl<V> UnwindSafe for LoggedEpochConsensus<V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V