quorum_set/quorum/quorum_bridge.rs
1#[cfg(doc)]
2use crate::QuorumIntersection;
3use crate::quorum::QuorumSet;
4
5/// Builds an intermediate quorum set that has [`QuorumIntersection`] with both
6/// the source and the target quorum set.
7pub trait QuorumBridge<Other>
8where
9 Self: QuorumSet,
10 Other: QuorumSet<Id = Self::Id>,
11{
12 /// Build a quorum set `X` so that `self ~ X ~ other`, where `~` is the
13 /// [`QuorumIntersection`] relation.
14 ///
15 /// Then `X` is the intermediate quorum set when changing membership from
16 /// `self` to `other`.
17 ///
18 /// E.g.(`cᵢcⱼ` is a joint of `cᵢ` and `cⱼ`, and no two distinct configs among `c₁`, `c₂`,
19 /// `c₃` have intersecting quorums):
20 /// - `c₁.bridge_to(c₁)` returns `c₁`
21 /// - `c₁.bridge_to(c₂)` returns `c₁c₂`
22 /// - `c₁c₂.bridge_to(c₂)` returns `c₂`
23 /// - `c₁c₂.bridge_to(c₁)` returns `c₁`
24 /// - `c₁c₂.bridge_to(c₃)` returns `c₂c₃`
25 fn bridge_to(&self, other: Other) -> Self;
26
27 /// Build the joint `X` of `self` and `other`: a set is a quorum of `X` exactly when it is a
28 /// quorum of both `self` and `other`.
29 ///
30 /// A change between two memberships with separate read and write quorum sets builds the joint
31 /// membership with two calls: one joins the old and the new read quorum sets, and one joins
32 /// the old and the new write quorum sets. Every joint read quorum is then a read quorum of both
33 /// the old and the new membership, and every joint write quorum is a write quorum of both.
34 ///
35 /// Let `~` be the [`QuorumIntersection`] relation. When `read ~ write` holds within the old
36 /// and within the new membership, these hold too:
37 /// - `old read ~ joint write` and `old write ~ joint read`
38 /// - `joint read ~ new write` and `joint write ~ new read`
39 /// - `joint read ~ joint write`
40 ///
41 /// E.g. `c₁c₂.joint_with(c₃)` returns `c₁c₂c₃`, where `cᵢcⱼ` is a joint of `cᵢ` and `cⱼ`.
42 fn joint_with(&self, other: Other) -> Self;
43}