aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/document/sync.rs12
-rw-r--r--src/swarm/peer/inbound.rs4
-rw-r--r--src/swarm/peer/keepalive.rs4
3 files changed, 11 insertions, 9 deletions
diff --git a/src/document/sync.rs b/src/document/sync.rs
index 41d818d..dab43b4 100644
--- a/src/document/sync.rs
+++ b/src/document/sync.rs
@@ -825,11 +825,11 @@ impl SyncSession {
true
}
- /// The peer said its `heads` outside the sync (a keepalive STATUS or a STATUS_REPLY):
- /// it has every change in their history. Automerge forgets changes as sent only when
- /// the peer's sync message says it has them, and a neighbour another parent brings the changes
- /// to (`known_to_peer`) sends us none while it has nothing to write: counted as sent,
- /// every change would stay so. So those in the history of `heads` count as sent no
+ /// The peer said its `heads` outside the sync (a STATUS or a STATUS_REPLY): it has
+ /// every change in their history. Automerge forgets changes as sent only when the
+ /// peer's sync message says it has them, and a neighbour another parent brings the
+ /// changes to (`known_to_peer`) sends us none while it has nothing to write: counted
+ /// as sent, every change would stay so. So those in the history of `heads` count as sent no
/// more, and the peer as having all up to `heads`: the next message to it carries
/// what lies beyond them, not those. Only forward: where `heads` aren't all ours, or
/// don't cover what the peer said before or what we take it to have (a message of
@@ -1391,7 +1391,7 @@ mod tests {
}
/// A neighbour another parent brings our changes to sends us no sync message: what
- /// counts as sent to it is forgotten once its keepalive says its heads, and nothing
+ /// counts as sent to it is forgotten once its STATUS says its heads, and nothing
/// goes to it again.
#[test]
fn heads_heard_forget_what_counts_as_sent() {
diff --git a/src/swarm/peer/inbound.rs b/src/swarm/peer/inbound.rs
index 8980fd3..9b701b5 100644
--- a/src/swarm/peer/inbound.rs
+++ b/src/swarm/peer/inbound.rs
@@ -200,8 +200,10 @@ pub(crate) async fn handle_message(
// no reason, as changes on their way to us make them differ while writes go on.
if !remote.announcing {
status_received(state, &peer).await;
- heard_heads(state, &peer, &remote);
}
+ // Announcements too: a neighbour heard from keeps none of its keepalives, so
+ // while writes go on its announcements are all it says of its heads.
+ heard_heads(state, &peer, &remote);
let local = on_status(state, &peer, &remote, reactivated).await;
if remote.announcing {
if local.heads != remote.heads {
diff --git a/src/swarm/peer/keepalive.rs b/src/swarm/peer/keepalive.rs
index a4def86..b4daf53 100644
--- a/src/swarm/peer/keepalive.rs
+++ b/src/swarm/peer/keepalive.rs
@@ -218,8 +218,8 @@ pub(super) async fn status_received(state: &AppState, peer: &str) {
}
}
-/// A keepalive 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.
+/// 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;