diff options
Diffstat (limited to 'src/remake/switch.rs')
| -rw-r--r-- | src/remake/switch.rs | 13 |
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, ©_heads).is_empty() { return Err("the document was replaced while preparing the switch".to_owned()); } let mut new_doc = new_doc; |
