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>>>
impl<P: Clone> ProbabilisticBroadcast<P, FairLossLink<Gossip<P>>>
Sourcepub fn new(
me: NodeId,
peers: impl IntoIterator<Item = NodeId>,
config: Config,
) -> Self
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>
impl<P: Clone, L: VolatileLink<Carried<P>>> ProbabilisticBroadcast<P, L>
Sourcepub fn with_link(
me: NodeId,
peers: impl IntoIterator<Item = NodeId>,
link: L,
config: Config,
) -> Self
pub fn with_link( me: NodeId, peers: impl IntoIterator<Item = NodeId>, link: L, config: Config, ) -> Self
Gossip among peers, over the link supplied.
Sourcepub fn remembered(&self) -> usize
pub fn remembered(&self) -> usize
How many identifiers this process is currently remembering. For the bound test.
Sourcepub fn has_delivered(&self, id: BroadcastId) -> bool
pub fn has_delivered(&self, id: BroadcastId) -> bool
Whether this process has delivered id and still remembers doing so.
Source§impl<P: Clone, L> ProbabilisticBroadcast<P, L>where
L: VolatileLink<Carried<P>>,
impl<P: Clone, L> ProbabilisticBroadcast<P, L>where
L: VolatileLink<Carried<P>>,
Trait Implementations§
Source§impl<P: Debug + Clone, L: Debug + VolatileLink<Carried<P>>> Debug for ProbabilisticBroadcast<P, L>
impl<P: Debug + Clone, L: Debug + VolatileLink<Carried<P>>> Debug for ProbabilisticBroadcast<P, L>
Source§impl<P: Clone, L> Protocol for ProbabilisticBroadcast<P, L>where
L: VolatileLink<Carried<P>>,
impl<P: Clone, L> Protocol for ProbabilisticBroadcast<P, L>where
L: VolatileLink<Carried<P>>,
Source§type Scope = <L as Protocol>::Scope
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
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>)
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>)
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>)
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 Entry = Infallible
type Entry = Infallible
Source§fn on_msg(&mut self, from: NodeId, msg: L::Msg, cx: &mut ProtoCx<'_, Self>)
fn on_msg(&mut self, from: NodeId, msg: L::Msg, cx: &mut ProtoCx<'_, Self>)
from.