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>
impl<V: Clone> LoggedEpochConsensus<V>
Sourcepub fn new(
me: NodeId,
peers: impl IntoIterator<Item = NodeId>,
ets: u64,
leader: NodeId,
state: State<V>,
retransmit: Duration,
) -> Self
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.
Sourcepub fn is_aborted(&self) -> bool
pub fn is_aborted(&self) -> bool
Whether this instance has been abandoned.
Sourcepub fn epoch_decision(&self) -> Option<&V>
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: Clone> Protocol for LoggedEpochConsensus<V>
impl<V: Clone> Protocol for LoggedEpochConsensus<V>
Source§type Entry = Infallible
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>)
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>)
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>)
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.