aboutsummaryrefslogtreecommitdiffstats
path: root/src/remake/switch.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 18:39:31 +0100
committertv <tv@krebsco.de>2026-10-31 18:39:31 +0100
commit4a6403d0242cf730a3f864c8d26e0ba15a98fcf0 (patch)
treefddd3aee30d2874c8bb07dad29731892a1ff610a /src/remake/switch.rs
parent88b3d05543561d5a34a4ff96b9a8ca9351e1a98d (diff)
remake coordination use document, not automerge
Diffstat (limited to 'src/remake/switch.rs')
-rw-r--r--src/remake/switch.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/remake/switch.rs b/src/remake/switch.rs
index 1238499..9aae748 100644
--- a/src/remake/switch.rs
+++ b/src/remake/switch.rs
@@ -20,7 +20,6 @@
use std::time::Duration;
-use automerge::{ActorId, AutoCommit, ChangeHash};
use tokio::sync::broadcast;
use tracing::{error, info, warn};
@@ -39,6 +38,7 @@ use crate::document::meta::{self, REMAKES};
use crate::document::replica::Epoch;
use crate::document::store;
use crate::document::store::paths_related;
+use crate::document::{ActorId, ChangeHash, Document};
use crate::locks::MutexExt;
const TICK: Duration = Duration::from_secs(1);
@@ -218,7 +218,7 @@ async fn switch<H: Host>(
// 2. Build (or reuse), verify and replay without holding any lock.
let (new_doc, copy_heads, mut stats) = tokio::task::spawn_blocking(
- move || -> Result<(AutoCommit, Vec<ChangeHash>, ReplayStats), String> {
+ move || -> Result<(Document, Vec<ChangeHash>, ReplayStats), String> {
let mut copy = copy;
let snapshot = match prebuilt {
Some(snapshot) => snapshot,
@@ -288,20 +288,17 @@ async fn switch<H: Host>(
pub(super) async fn swap_in<H: Host>(
host: &H,
target: Epoch,
- new_doc: AutoCommit,
+ new_doc: Document,
copy_heads: Vec<ChangeHash>,
translator: Translator,
-) -> Result<(AutoCommit, ReplayStats), String> {
+) -> Result<(Document, ReplayStats), String> {
// 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);
let old = host
.switch_epoch(target, move |live| {
// Only one worker switches, but be sure the copy still describes the live document.
- if !copy_heads
- .iter()
- .all(|head| live.get_change_by_hash(head).is_some())
- {
+ if !crate::document::changes::missing(live, &copy_heads).is_empty() {
return Err("the document was replaced while preparing the switch".to_owned());
}
let mut new_doc = new_doc;