diff options
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( |
