diff options
Diffstat (limited to 'src/remake/switch.rs')
| -rw-r--r-- | src/remake/switch.rs | 23 |
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. |
