aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/sync.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm/sync.rs')
-rw-r--r--src/swarm/sync.rs20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs
index bb99547..65a02ea 100644
--- a/src/swarm/sync.rs
+++ b/src/swarm/sync.rs
@@ -427,7 +427,7 @@ pub(crate) async fn handle_sync(
{
let mut peer_state = peer_state_mutex.lock().await;
peer_state.reports_ready = Some(from_ready);
- peer_state.last_heads = Some((epoch, transport::HeadsSummary::of(spec.to.clone())));
+ peer_state.last_heads = Some((epoch, spec.stands()));
peer_state.last_sync_rx = Some(Instant::now());
peer_state.sync.answered_by_offer();
}
@@ -509,7 +509,7 @@ pub(crate) async fn handle_sync(
peer_state.reports_ready = Some(from_ready);
// What it says it has (`swarm::relay::unreached`).
peer_state.last_heads =
- Some((epoch, transport::HeadsSummary::of(message.heads().to_vec())));
+ Some((epoch, message.stands()));
let (taken, took) = crate::document::passing::take(
&mut peer_state.sync,
&mut replica,
@@ -855,19 +855,9 @@ async fn download_and_apply_delta(
/// document was replaced (an epoch switch, a rejoin: its heads are no longer ours).
async fn own_changes(
state: &AppState,
- seen_heads: &mut Vec<crate::document::ChangeHash>,
+ seen: &mut crate::document::passing::Mark,
) -> Option<Vec<crate::document::UnitId>> {
- let replica = state.doc.read().await;
- let before = std::mem::replace(seen_heads, replica.heads().to_vec());
- if !crate::document::changes::holds_all(&replica.doc, &before) {
- return None;
- }
- let since = crate::document::changes::since(&replica.doc, &before);
- since
- .authors
- .into_iter()
- .find(|(author, _)| author == state.local_id())
- .map(|(_, hashes)| hashes.into_iter().map(Into::into).collect())
+ crate::document::passing::own_since(&*state.doc.read().await, seen, state.local_id())
}
pub(crate) async fn run_sync_worker(state: AppState, mut rx: mpsc::UnboundedReceiver<SyncEvent>) {
@@ -875,7 +865,7 @@ pub(crate) async fn run_sync_worker(state: AppState, mut rx: mpsc::UnboundedRece
let mut document_dirty = false;
// The heads as of the last document change looked at: what came since, and which of
// it is ours (`own_changes`).
- let mut seen_heads = state.doc.read().await.heads().to_vec();
+ let mut seen_heads = crate::document::passing::mark(&*state.doc.read().await);
info!("Starting the sync worker");