diff options
| author | tv <tv@krebsco.de> | 2026-11-04 05:14:12 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-04 05:14:12 +0100 |
| commit | 40073ebf9570464a69a928eba9c51b4dad6e699a (patch) | |
| tree | f82fdd38ed24603be5c66740af39a786f213cd1a /src/swarm/relay.rs | |
| parent | e8d1cbddcaec18f79f54cad671f15bbaa189673b (diff) | |
announcements answered when lacking
A neighbour now answers an announcement only if it lacks some of the
announced heads. Heads that merely differ are no longer enough, since
they do while writes go on. The check reads the document, so it runs
off the message consumer, as the pull check already does.
Diffstat (limited to 'src/swarm/relay.rs')
| -rw-r--r-- | src/swarm/relay.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/swarm/relay.rs b/src/swarm/relay.rs index 53c1065..99c1381 100644 --- a/src/swarm/relay.rs +++ b/src/swarm/relay.rs @@ -5,7 +5,7 @@ //! further by itself but along a writer's tree. So after applying changes from one //! neighbour, a node *announces* //! its new heads to its other neighbours with a STATUS (heads, about 100 bytes, not the -//! changes; no keepalive, and answered only by a neighbour whose heads differ). A +//! changes; no keepalive, and answered only by a neighbour that lacks some of them). A //! neighbour that sees heads it lacks *pulls*: it enters the //! announced heads as the peer's heads in its sync state, Automerge asks for what's //! missing (`need`), and the announcer answers with exactly those changes. Regular @@ -218,6 +218,12 @@ pub(crate) struct Pulling { waiting: HashMap<String, transport::Status>, } +/// Whether we lack any of `heads` (with a digest, any of the sample it lists). +pub(crate) async fn lacks(state: &AppState, heads: &HeadsSummary) -> bool { + let replica = state.doc.read().await; + !crate::document::changes::missing(&replica.doc, heads.listed()).is_empty() +} + /// A keepalive from `peer`: if it has heads we lack, pull them (one peer at a time; a /// busy slot queues the peer). Returns whether a pull started. pub(crate) async fn pull_if_behind( |
