Skip to main content

FloodingConsensus

Struct FloodingConsensus 

Source
pub struct FloodingConsensus<P: Clone + Ord, L: VolatileLink<Flood<P>> = PerfectLink<Flood<P>>> { /* private fields */ }
Expand description

Regular consensus in the fail-stop model, over best-effort broadcast and a failure detector.

L is the link under the broadcast, and is a parameter rather than a fixed type: what this stack needs is a link speaking pl::Cmd and pl::Ind, not one particular implementation. An application with its own driver-backed link runs this consensus over it unedited. It defaults to PerfectLink, so the ordinary stack is still written FloodingConsensus<P>.

Implementations§

Source§

impl<P: Clone + Ord, L: VolatileLink<Flood<P>>> FloodingConsensus<P, L>

Consensus among members, over a link the caller supplies.

The link is anything satisfying crate::link::Link; this layer never names an implementation.

Source§

impl<P: Clone + Ord> FloodingConsensus<P, PerfectLink<Flood<P>>>

Source

pub fn new( me: NodeId, members: impl IntoIterator<Item = NodeId>, retransmit: Duration, heartbeat: Duration, detect_after: Duration, ) -> Self

Consensus among members, which must include me.

detect_after must exceed heartbeat plus the network’s delivery bound, or the detector will accuse correct processes and agreement can break — which is the whole subject of this module’s documentation.

Source

pub fn correct(&self) -> impl Iterator<Item = NodeId> + '_

The processes still believed correct, in a stable order.

Source

pub fn round(&self) -> u64

The round this process is currently in.

Source

pub fn decision(&self) -> Option<&P>

What this process decided, if it has.

Source

pub fn heard_from(&self, round: u64) -> impl Iterator<Item = NodeId> + '_

Who this process heard from in round, for tests watching the guard form.

Source

pub fn rounds_recorded(&self) -> usize

How many rounds hold state. Bounded by the membership; see the space note above.

Source

pub fn state_entries(&self) -> usize

Every entry held across every round — the measure a bounded-space test asserts on.

Trait Implementations§

Source§

impl<P: Debug + Clone + Ord, L: Debug + VolatileLink<Flood<P>>> Debug for FloodingConsensus<P, L>

Source§

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

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

impl<P: Clone + Ord, L: VolatileLink<Flood<P>>> Protocol for FloodingConsensus<P, L>

Source§

type Scope = Infallible

No session beneath, so no scope end can be constructed — as for both children.

Source§

type Meta = Infallible

Keeps nothing durably: a crash loses everything this protocol knows.

Source§

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

Failure detection begins here, as Module 2.6 has it. It used to need a Start command because there was no init event to hang the detector’s first timer on.

Source§

type Cmd = Cmd<P>

Requests from the layer above.
Source§

type Ind = Ind<P>

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

type Msg = Wire<<L as Protocol>::Msg>

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

type Note = Note

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

type Entry = Infallible

The durable entries this protocol appends: what accumulates.
Source§

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

Handle a request from the layer above.
Source§

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

Handle a message received from from.
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_recovery( &mut self, _cx: &mut Cx<'_, Self::Msg, Self::Ind, Self::Note, Self::Meta, Self::Entry>, )

Resume after a crash, reading what survived. 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<P, L> Freeze for FloodingConsensus<P, L>
where P: Freeze, L: Freeze,

§

impl<P, L> RefUnwindSafe for FloodingConsensus<P, L>

§

impl<P, L> Send for FloodingConsensus<P, L>
where P: Send, L: Send,

§

impl<P, L> Sync for FloodingConsensus<P, L>
where P: Sync, L: Sync,

§

impl<P, L> Unpin for FloodingConsensus<P, L>
where P: Unpin, L: Unpin,

§

impl<P, L> UnsafeUnpin for FloodingConsensus<P, L>
where P: UnsafeUnpin, L: UnsafeUnpin,

§

impl<P, L> UnwindSafe for FloodingConsensus<P, L>

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