diff options
Diffstat (limited to 'src/state/host.rs')
| -rw-r--r-- | src/state/host.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/state/host.rs b/src/state/host.rs index 912a187..a878381 100644 --- a/src/state/host.rs +++ b/src/state/host.rs @@ -6,7 +6,6 @@ use std::sync::Arc; use std::time::Duration; use anyhow::Result; -use automerge::{AutoCommit, ChangeHash}; use tokio::sync::broadcast; use tokio::time::Instant; use tracing::debug; @@ -14,6 +13,7 @@ use tracing::debug; use super::{AppState, HelloState, NodeLifecycle, StaleView, Standing}; use crate::document::replica::Epoch; use crate::document::store::ChangeSet; +use crate::document::{ChangeHash, Document}; use crate::remake::{Host, PeerSummary, RemakeState}; impl AppState { @@ -86,14 +86,14 @@ impl Host for AppState { crate::swarm::skew::measure(self).await } - fn electorate(&self, doc: &AutoCommit, now: crate::clock::UnixMillis) -> Vec<String> { + fn electorate(&self, doc: &Document, now: crate::clock::UnixMillis) -> Vec<String> { crate::swarm::members::electorate(doc, now.as_u64(), self.electorate_window) } fn fetch_change( &self, hash: ChangeHash, - ) -> impl Future<Output = Result<automerge::Change>> + Send { + ) -> impl Future<Output = Result<crate::document::Change>> + Send { let state = self.clone(); async move { let peers = state.active_peers_on_local_epoch().await; @@ -184,7 +184,7 @@ impl Host for AppState { } } - fn set_stale_view(&self, view: Option<(Epoch, AutoCommit)>) { + fn set_stale_view(&self, view: Option<(Epoch, Document)>) { self.set_stale(view.map(|(epoch, doc)| StaleView { epoch, doc: Arc::new(doc), @@ -209,7 +209,7 @@ impl Host for AppState { fn read_doc<T, F>(&self, f: F) -> impl Future<Output = T> + Send where - F: FnOnce(&AutoCommit) -> T + Send + 'static, + F: FnOnce(&Document) -> T + Send + 'static, T: Send + 'static, { let state = self.clone(); @@ -218,7 +218,7 @@ impl Host for AppState { fn commit_doc<T, E, F>(&self, f: F) -> impl Future<Output = Result<T, E>> + Send where - F: FnOnce(&mut AutoCommit) -> Result<T, E> + Send + 'static, + F: FnOnce(&mut Document) -> Result<T, E> + Send + 'static, T: Send + 'static, E: Send + 'static, { @@ -230,16 +230,16 @@ impl Host for AppState { &self, epoch: Epoch, f: F, - ) -> impl Future<Output = Result<AutoCommit, E>> + Send + ) -> impl Future<Output = Result<Document, E>> + Send where - F: FnOnce(&mut AutoCommit) -> Result<AutoCommit, E> + Send + 'static, + F: FnOnce(&mut Document) -> Result<Document, E> + Send + 'static, E: Send + 'static, { let state = self.clone(); async move { let swapped = { let state = state.clone(); - tokio::task::spawn_blocking(move || -> Result<AutoCommit, E> { + tokio::task::spawn_blocking(move || -> Result<Document, E> { let mut replica = state.doc.blocking_write(); let new_doc = f(&mut replica.doc)?; let old_doc = std::mem::replace(&mut replica.doc, new_doc); |
