From 2a475153b715c954935ae46d3773ffbf3d007f03 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 29 Nov 2026 04:05:41 +0000 Subject: document: where a document stands, and a peer, is the document's to compare document::passing: a Mark, where a document stood, by which what changed since and the node's own units since are told (changed_since, own_since: the change publisher, the sync worker); and of where a peer says it stands, what the document lacks, whether the peer holds what the document held, a pull of what is lacking, and what it has counting as sent no more (lacking, peer_holds, pull, heard: the relay, keepalives). The published stamp gives its summary and its mark. --- src/swarm/peer/keepalive.rs | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src/swarm/peer/keepalive.rs') diff --git a/src/swarm/peer/keepalive.rs b/src/swarm/peer/keepalive.rs index 51ff14a..72ab033 100644 --- a/src/swarm/peer/keepalive.rs +++ b/src/swarm/peer/keepalive.rs @@ -180,11 +180,7 @@ pub(crate) async fn local_status(state: &AppState, peer: &str) -> transport::Sta // and reading them doesn't wait for a sync message being applied. let (heads, epoch, epoch_seq) = { let stamp = state.stamp.borrow(); - ( - transport::HeadsSummary::of(stamp.heads.to_vec()), - stamp.epoch, - stamp.epoch_seq, - ) + (stamp.summary(), stamp.epoch, stamp.epoch_seq) }; let syncs_with_you = match state.get_peer_state(peer).await { Some(peer_state) => peer_state.lock().await.syncs_on(epoch), @@ -221,14 +217,15 @@ pub(super) async fn status_received(state: &AppState, peer: &str) { /// A STATUS, or a STATUS_REPLY, said the peer's heads: what it has counts as sent to it /// no more (`SyncSession::heard_heads`). Off the consumer: it takes the document's lock. pub(super) fn heard_heads(state: &AppState, peer: &str, remote: &transport::Status) { - let Some(heads) = remote.heads.heads() else { - return; - }; - if heads.is_empty() || remote.epoch != state.local_epoch() { + if remote.heads.heads().is_none_or(<[_]>::is_empty) || remote.epoch != state.local_epoch() { return; } - let (state, peer, heads, epoch) = - (state.clone(), peer.to_owned(), heads.to_vec(), remote.epoch); + let (state, peer, theirs, epoch) = ( + state.clone(), + peer.to_owned(), + remote.heads.clone(), + remote.epoch, + ); tokio::spawn(async move { let Some(peer_state) = state.get_peer_state(&peer).await else { return; @@ -238,11 +235,7 @@ pub(super) fn heard_heads(state: &AppState, peer: &str, remote: &transport::Stat if replica.epoch != epoch { return; } - peer_state - .lock() - .await - .sync - .heard_heads(&replica.doc, &heads); + crate::document::passing::heard(&mut peer_state.lock().await.sync, &replica.doc, &theirs); }); } -- cgit v1.3.1