diff options
| author | tv <tv@krebsco.de> | 2026-11-29 04:05:41 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-29 04:08:47 +0000 |
| commit | 2a475153b715c954935ae46d3773ffbf3d007f03 (patch) | |
| tree | 8ebe8a5d6cdaf9869822f95fe2ac7eca0c10cf7f /src/swarm/peer/keepalive.rs | |
| parent | 2ae7562083f5f96490f90e9398762cf6a024d51e (diff) | |
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.
Diffstat (limited to 'src/swarm/peer/keepalive.rs')
| -rw-r--r-- | src/swarm/peer/keepalive.rs | 25 |
1 files changed, 9 insertions, 16 deletions
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); }); } |
