summaryrefslogtreecommitdiffstats
path: root/src/remake/delta.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-25 19:55:59 +0100
committertv <tv@krebsco.de>2026-10-25 19:55:59 +0100
commit866924934d635df8a8f222a022f806c44581a5f5 (patch)
tree43add97297eaf20f31877657bb893bec078cea29 /src/remake/delta.rs
parentfbfc766d80005dd5686c9acc1f8c16883c5e1ccc (diff)
nodes keep list of every actor ID they've used
Diffstat (limited to 'src/remake/delta.rs')
-rw-r--r--src/remake/delta.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/remake/delta.rs b/src/remake/delta.rs
index c8f6b7c..51cc409 100644
--- a/src/remake/delta.rs
+++ b/src/remake/delta.rs
@@ -159,22 +159,23 @@ pub(crate) struct Missing {
/// Splits `doc`'s history against a snapshot `clock`: a change (actor, seq) is in the
/// snapshot iff seq <= clock[actor].
///
-/// Only changes this node wrote itself (actor `own`) are worth replaying: other nodes'
-/// changes after the base were replayed by those nodes when they switched, and replaying
-/// them again would overwrite newer writes in the new epoch with stale ones.
+/// Only changes this node wrote itself (any of the actors in `own`: one per run and
+/// epoch) are worth replaying when it rejoins: other nodes' changes after the base were
+/// replayed by the nodes that switched, and replaying them again would overwrite newer
+/// writes in the new epoch with stale ones.
pub(crate) fn missing_from_snapshot(
doc: &mut AutoCommit,
clock: &BTreeMap<String, u64>,
- own: &ActorId,
+ own: &[ActorId],
) -> Missing {
- let own_hex = own.to_string();
+ let own_hex: HashSet<String> = own.iter().map(ActorId::to_string).collect();
let changes: Vec<(ChangeHash, Vec<ChangeHash>, bool)> = doc
.get_changes(&[])
.iter()
.map(|change| {
let actor = change.actor_id().to_string();
let in_snapshot = clock.get(&actor).is_some_and(|&seq| change.seq() <= seq);
- let own_missing = actor == own_hex && !in_snapshot;
+ let own_missing = own_hex.contains(&actor) && !in_snapshot;
(change.hash(), change.deps().to_vec(), own_missing)
})
.collect();
@@ -370,7 +371,7 @@ mod tests {
doc.commit();
let after = doc.get_heads();
- let missing = missing_from_snapshot(&mut doc, &clock, &own);
+ let missing = missing_from_snapshot(&mut doc, &clock, std::slice::from_ref(&own));
assert_eq!(missing.own, 1);
assert_eq!(missing.before, with_foreign);
assert_ne!(missing.before, base);
@@ -381,7 +382,7 @@ mod tests {
// Nothing of ours missing: nothing to replay.
let full: BTreeMap<String, u64> = [(own.to_string(), 2)].into_iter().collect();
- let none = missing_from_snapshot(&mut doc, &full, &own);
+ let none = missing_from_snapshot(&mut doc, &full, std::slice::from_ref(&own));
assert_eq!(none.own, 0);
let mut heads = after.clone();
heads.sort();