pub struct LazyProbabilisticBroadcast<P, L = FairLossLink<Recovery<P>>, G = FairLossLink<Carried<Data<P>>>>where
P: Clone + Serialize + DeserializeOwned,
L: VolatileLink<Recovery<P>>,
L::Scope: Clone,
G: VolatileLink<Carried<Data<P>>, Scope = L::Scope>,{ /* private fields */ }Expand description
Gossip with recovery.
Two links, both parameters: L carries the recovery traffic and G carries the gossip. Over
sessions both are session links — two instances each holding one epoch per peer, both handed
every scope event, on one wire — which is how crate::uniform_reliable_broadcast already puts
a broadcast and a detector together. Their scopes must agree (G::Scope = L::Scope), because a
scope event reaching this layer is one event about one session and goes to both.
Implementations§
Source§impl<P> LazyProbabilisticBroadcast<P, FairLossLink<Recovery<P>>>
impl<P> LazyProbabilisticBroadcast<P, FairLossLink<Recovery<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
Lazy probabilistic broadcast among peers, over the fair-loss links the book names.
Source§impl<P, L> LazyProbabilisticBroadcast<P, L>
impl<P, L> LazyProbabilisticBroadcast<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
Lazy probabilistic broadcast, over the link supplied for its recovery traffic and the book’s fair-loss link for the gossip.
Only for a recovery link that reports no boundary: the gossip beneath runs over a fair-loss
link here, and the two links’ scopes have to agree. Over sessions use
LazyProbabilisticBroadcast::with_links with a session link for both.
Source§impl<P, L, G> LazyProbabilisticBroadcast<P, L, G>where
P: Clone + Serialize + DeserializeOwned,
L: VolatileLink<Recovery<P>>,
L::Scope: Clone,
G: VolatileLink<Carried<Data<P>>, Scope = L::Scope>,
impl<P, L, G> LazyProbabilisticBroadcast<P, L, G>where
P: Clone + Serialize + DeserializeOwned,
L: VolatileLink<Recovery<P>>,
L::Scope: Clone,
G: VolatileLink<Carried<Data<P>>, Scope = L::Scope>,
Sourcepub fn with_links(
me: NodeId,
peers: impl IntoIterator<Item = NodeId>,
gossip: G,
recovery: L,
config: Config,
) -> Self
pub fn with_links( me: NodeId, peers: impl IntoIterator<Item = NodeId>, gossip: G, recovery: L, config: Config, ) -> Self
Lazy probabilistic broadcast over two links: gossip beneath the eager broadcast that
disseminates data, recovery for the requests and answers that repair gaps.
Sourcepub fn gossip_link(&self) -> &G
pub fn gossip_link(&self) -> &G
The link the gossip travels over.
Sourcepub fn recovery_link(&self) -> &L
pub fn recovery_link(&self) -> &L
The link the recovery traffic travels over.
Sourcepub fn next_expected_of(&self, sender: Sender) -> u64
pub fn next_expected_of(&self, sender: Sender) -> u64
next[s], which is one until this process has delivered anything from s.
Sourcepub fn next_expected(&self, from: NodeId) -> u64
pub fn next_expected(&self, from: NodeId) -> u64
next[s] for the incarnation of from most recently heard from, or one if none has been.
Sourcepub fn latest(&self, from: NodeId) -> Option<Sender>
pub fn latest(&self, from: NodeId) -> Option<Sender>
The incarnation of from most recently admitted, if any.
Sourcepub fn incarnations_of(&self, from: NodeId) -> usize
pub fn incarnations_of(&self, from: NodeId) -> usize
How many incarnations of from this process keeps state for.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
How many messages this process is holding ahead of a gap.
Sourcepub fn stored_count(&self) -> usize
pub fn stored_count(&self) -> usize
How many copies this process is holding for answering requests.
Sourcepub fn has_stored(&self, origin: NodeId, seq: u64) -> bool
pub fn has_stored(&self, origin: NodeId, seq: u64) -> bool
Whether this process could answer a request for seq from the incarnation of origin
most recently heard from.
Trait Implementations§
Source§impl<P, L, G> Protocol for LazyProbabilisticBroadcast<P, L, G>where
P: Clone + Serialize + DeserializeOwned,
L: VolatileLink<Recovery<P>>,
L::Scope: Clone,
G: VolatileLink<Carried<Data<P>>, Scope = L::Scope>,
impl<P, L, G> Protocol for LazyProbabilisticBroadcast<P, L, G>where
P: Clone + Serialize + DeserializeOwned,
L: VolatileLink<Recovery<P>>,
L::Scope: Clone,
G: VolatileLink<Carried<Data<P>>, Scope = L::Scope>,
Source§type Meta = Infallible
type Meta = Infallible
Keeps nothing durably.
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 ⟩ do lsn := lsn + 1; trigger ⟨ upb, Broadcast | [DATA, …] ⟩.
Note what is not here: no delivery to self. The eager child beneath delivers a broadcast
to its own process, and that arrives back through on_upb_deliver like any other, which is
what puts this process’s own messages through the same sequence check as everyone else’s.
Source§fn on_timer(&mut self, id: TimerId, cx: &mut ProtoCx<'_, Self>)
fn on_timer(&mut self, id: TimerId, cx: &mut ProtoCx<'_, Self>)
upon event ⟨ Timeout | s, sn ⟩ do if sn > next[s] then next[s] := sn + 1.
The gap is abandoned, and sn with it — the book skips past the message the timer was
waiting on, not to it. Whatever is now deliverable is released by the standing condition,
which is why the drain follows.
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>)
Both children run over the same session, so both are told when it ends or begins.
Source§fn on_init(&mut self, cx: &mut ProtoCx<'_, Self>)
fn on_init(&mut self, cx: &mut ProtoCx<'_, Self>)
Name this incarnation, then start the children. Runs on every restart, which is the point.
Source§type Msg = Wire<<G as Protocol>::Msg, <L as Protocol>::Msg>
type Msg = Wire<<G as Protocol>::Msg, <L as Protocol>::Msg>
Source§type Scope = <L as Protocol>::Scope
type Scope = <L as Protocol>::Scope
Source§type Entry = Infallible
type Entry = Infallible
Source§fn on_msg(&mut self, from: NodeId, msg: Self::Msg, cx: &mut ProtoCx<'_, Self>)
fn on_msg(&mut self, from: NodeId, msg: Self::Msg, cx: &mut ProtoCx<'_, Self>)
from.