Function hydro_test::cluster::paxos::paxos_core
source · pub unsafe fn paxos_core<'a, P: PaxosPayload, R>(
proposers: &Cluster<'a, Proposer>,
acceptors: &Cluster<'a, Acceptor>,
r_to_acceptors_checkpoint: Stream<(ClusterId<R>, usize), Cluster<'a, Acceptor>, Unbounded, NoOrder>,
c_to_proposers: impl FnOnce(Stream<Ballot, Cluster<'a, Proposer>, Unbounded>) -> Stream<P, Cluster<'a, Proposer>, Unbounded>,
config: PaxosConfig,
) -> (Stream<Ballot, Cluster<'a, Proposer>, Unbounded>, Stream<(usize, Option<P>), Cluster<'a, Proposer>, Unbounded, NoOrder>)
Expand description
Implements the core Paxos algorithm, which uses a cluster of propsers and acceptors to sequence payloads being sent to the proposers.
Proposers that currently are the leader will work with acceptors to sequence incoming payloads, but may drop payloads if they are not the lader or lose leadership during the commit process.
Returns a stream of ballots, where new values are emitted when a new leader is elected, and a stream of sequenced payloads with an index and optional payload (in the case of holes in the log).
§Safety
When the leader is stable, the algorithm will commit incoming payloads to the leader in deterministic order. However, when the leader is changing, payloads may be non-deterministically dropped. The stream of ballots is also non-deterministic because leaders are elected in a non-deterministic process.