aboutsummaryrefslogtreecommitdiffstats
path: root/src/remake/switch.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-17 04:13:38 +0000
committertv <tv@krebsco.de>2026-11-17 05:33:14 +0100
commit44a61c46160843d917a1da24bc8e364c5109960d (patch)
tree2b32d02f03cde62e97f43629452431941416c564 /src/remake/switch.rs
parent171f1fcabcdb62b93696f5028120e9d5390b118a (diff)
remake: holding a store, of two epochs decided for one, the lower ID
In a swarm holding a store, of two epochs decided for one, by a coordinator that wrote two decisions or by remakes decided at once, a node follows the one with the lower ID, and a node on the other rejoins it, however many peers are on each (`docs/store.md`, Remakes): a node switches to the lower of two committed remakes of its epoch, follows the lowest of several newer epochs, and a ready node rejoins a lower one of its own generation that enough peers serve.
Diffstat (limited to 'src/remake/switch.rs')
-rw-r--r--src/remake/switch.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/remake/switch.rs b/src/remake/switch.rs
index 657b0f5..e56cd8c 100644
--- a/src/remake/switch.rs
+++ b/src/remake/switch.rs
@@ -117,6 +117,29 @@ async fn check<H: Host>(host: &H) {
return catchup::check(host).await;
}
[(id, record)] => (id.clone(), record.clone()),
+ // Holding a store, of two epochs decided for one, the lower ID (`docs/store.md`,
+ // Remakes).
+ #[cfg(feature = "federation")]
+ several
+ if host
+ .read_doc(|doc| {
+ matches!(
+ crate::access::policy::of(doc),
+ crate::access::policy::Policy::Store(_)
+ )
+ })
+ .await =>
+ {
+ let lowest = several
+ .iter()
+ .filter(|(_, record)| !record.contested)
+ .min_by_key(|(_, record)| record.committed_epoch().map(|epoch| epoch.id));
+ let Some((id, record)) = lowest else {
+ error!("Decisions on these remakes disagree; not switching on my own");
+ return catchup::check(host).await;
+ };
+ (id.clone(), record.clone())
+ }
several => {
// Majority voting prevents this; never guess which one is right. Peers
// that did switch can still be followed.