diff options
| author | tv <tv@krebsco.de> | 2026-11-07 22:35:21 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-07 22:35:21 +0100 |
| commit | 1a5b5ea02909e6c176ebd85d395e47fe15fcdba0 (patch) | |
| tree | 0e365788ce87a372353aae7a03403af0daf284d4 /src/remake/switch.rs | |
| parent | 046b738c74f62469f7a080415690e2dacd85e1e6 (diff) | |
remake: replays keep their writers
A remake's replay writes each value as the user who wrote it,
splitting where several users wrote under a path, so replays are
judged as the original writes.
Auth plan M6 (remakes, 2.4).
Diffstat (limited to 'src/remake/switch.rs')
| -rw-r--r-- | src/remake/switch.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/remake/switch.rs b/src/remake/switch.rs index 4c72b39..dd08b38 100644 --- a/src/remake/switch.rs +++ b/src/remake/switch.rs @@ -216,6 +216,7 @@ async fn switch<H: Host>( let actor = ActorId::random(); host.remake().add_own_actor(actor.clone()); let new_actor = actor.clone(); + let node = host.node_id(); // 2. Build (or reuse), verify and replay without holding any lock. let (new_doc, copy_heads, mut stats) = tokio::task::spawn_blocking( @@ -233,8 +234,9 @@ async fn switch<H: Host>( )); } - // A fresh actor: this node's writes in the new epoch. + // A fresh actor: this node's writes in the new epoch, made by it. let mut doc = snapshot.doc.with_actor(actor); + crate::document::replica::authored(&mut doc, &node); let heads = copy.get_heads(); @@ -248,8 +250,15 @@ async fn switch<H: Host>( } // Each write at the time it was made, so later replays judge by it. - let stats = - delta::replay_newest(©, &base, &heads, &mut doc, &translator, superseded); + let stats = delta::replay_newest( + ©, + &base, + &heads, + &mut doc, + &node, + &translator, + superseded, + ); Ok((doc, heads, stats)) }, ) @@ -302,6 +311,7 @@ pub(super) async fn swap_in<H: Host>( translator: Translator, ) -> Result<(Document, ReplayStats), String> { let superseded = host.superseded(); + let node = host.node_id(); // The closure runs on the blocking pool; its replay numbers come back through this. let late_stats = std::sync::Arc::new(std::sync::Mutex::new(ReplayStats::default())); let late_out = std::sync::Arc::clone(&late_stats); @@ -318,6 +328,7 @@ pub(super) async fn swap_in<H: Host>( ©_heads, &live_heads, &mut new_doc, + &node, &translator, superseded, ); |
