Skip to main content

ProbabilisticBroadcast

Struct ProbabilisticBroadcast 

Source
pub struct ProbabilisticBroadcast<P: Clone, L: VolatileLink<Carried<P>> = FairLossLink<Gossip<P>>> { /* private fields */ }
Expand description

Gossip: relay to a random few, for a bounded number of rounds.

L is the link beneath and it is a parameter, so this composes over a perfect link, a session link, or an application’s own. It bounds on crate::link::Link rather than anything narrower because gossip needs nothing of a scope boundary beyond passing it upward.

Implementations§

Source§

impl<P: Clone> ProbabilisticBroadcast<P, FairLossLink<Gossip<P>>>

Source

pub fn new( me: NodeId, peers: impl IntoIterator<Item = NodeId>, config: Config, ) -> Self

Gossip among peers, over the fair-loss link Algorithm 3.9 names.

The book says Uses: FairLossPointToPointLinks and this default honours it. A perfect link would retransmit until delivery, which masks the probabilistic guarantee this abstraction exists to provide — and would never fall silent, because the stubborn link beneath it re-sends everything it has ever sent. Gossip over a link that does not lose is gossip with nothing to do.

Source§

impl<P: Clone, L: VolatileLink<Carried<P>>> ProbabilisticBroadcast<P, L>

Gossip among peers, over the link supplied.

Source

pub fn remembered(&self) -> usize

How many identifiers this process is currently remembering. For the bound test.

Source

pub fn has_delivered(&self, id: BroadcastId) -> bool

Whether this process has delivered id and still remembers doing so.

Source

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

The processes this instance gossips among, in a stable order.

Source§

impl<P: Clone, L> ProbabilisticBroadcast<P, L>
where L: VolatileLink<Carried<P>>,

The link beneath.

Trait Implementations§

Source§

impl<P: Debug + Clone, L: Debug + VolatileLink<Carried<P>>> Debug for ProbabilisticBroadcast<P, L>

Source§

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

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

impl<P: Clone, L> Protocol for ProbabilisticBroadcast<P, L>
where L: VolatileLink<Carried<P>>,

Source§

type Scope = <L as Protocol>::Scope

Whatever the link’s guarantees are conditional on. This layer adds no condition of its own and cannot bridge the link’s.

Source§

type Meta = Infallible

Keeps nothing durably: a crash loses everything this protocol knows, which is why PB2 is scoped to the window within an incarnation and says nothing across one.

Source§

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

upon event ⟨ pb, Broadcast | m ⟩ — deliver to self, then gossip.

Source§

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

Name this incarnation. Runs on a first start and on every restart, which is the point: a restarted process is a new incarnation and its identifiers must say so.

Source§

fn on_scope_event(&mut self, scope: L::Scope, cx: &mut ProtoCx<'_, Self>)

Hand the scope ending down to the link. The trait’s default would drop it.

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 = <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_msg(&mut self, from: NodeId, msg: L::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

Auto Trait Implementations§

§

impl<P, L> Freeze for ProbabilisticBroadcast<P, L>
where L: Freeze,

§

impl<P, L> RefUnwindSafe for ProbabilisticBroadcast<P, L>
where L: RefUnwindSafe, <L as Protocol>::Ind: RefUnwindSafe,

§

impl<P, L> Send for ProbabilisticBroadcast<P, L>
where L: Send, <L as Protocol>::Ind: Send,

§

impl<P, L> Sync for ProbabilisticBroadcast<P, L>
where L: Sync, <L as Protocol>::Ind: Sync,

§

impl<P, L> Unpin for ProbabilisticBroadcast<P, L>
where L: Unpin, <L as Protocol>::Ind: Unpin,

§

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

§

impl<P, L> UnwindSafe for ProbabilisticBroadcast<P, L>
where L: UnwindSafe, <L as Protocol>::Ind: UnwindSafe,

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