diff options
| author | tv <tv@krebsco.de> | 2026-11-30 17:57:55 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-30 17:57:55 +0000 |
| commit | 08ec65219991c7413c8cdef4ce77434f2a121331 (patch) | |
| tree | 2c9d6f07e435a1ae37c62571579b170374cfbb70 /src/swarm/peer/keepalive.rs | |
| parent | 00e88cd983766abec32b5a14a8cbf20932a27f3c (diff) | |
A node of both kinds, for a swarm to move to sets by (--store-both)
With store-document, store-both has the node hold its store in the
Automerge document too, and sync with nodes of either kind:
* it says to each peer the kind that peer holds, and passes its set on
to those that hold sets (swarm::set::holds_a_set), the Automerge
document to the others;
* what its set takes of the document goes on to the peers on sets
(Holding::unpassed), and what its set takes of them is put into the
document, as events it lacks are (Holding::lacking);
* its entry in the document is put as its entry in the set
(swarm::set::mirror_entry), and it reads the members of both;
* without the set's file yet, its set is made of the store as it reads
it of its document, with what store-file kept of its own.
A simulation: two nodes on the Automerge document, one on a set, one
of both between them; an event put on either side reaches all four.
Diffstat (limited to 'src/swarm/peer/keepalive.rs')
| -rw-r--r-- | src/swarm/peer/keepalive.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/swarm/peer/keepalive.rs b/src/swarm/peer/keepalive.rs index 6ab49d8..bbcc6e3 100644 --- a/src/swarm/peer/keepalive.rs +++ b/src/swarm/peer/keepalive.rs @@ -182,13 +182,21 @@ pub(crate) async fn local_status(state: &AppState, peer: &str) -> transport::Sta let stamp = state.stamp.borrow(); (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), - None => false, + let (syncs_with_you, _of_a_set) = match state.get_peer_state(peer).await { + Some(peer_state) => { + let peer_state = peer_state.lock().await; + ( + peer_state.syncs_on(epoch), + peer_state + .kind + .is_some_and(|kind| kind != crate::document::KIND), + ) + } + None => (false, false), }; - // Where a set of events carries the store, where that stands (`swarm::set`). + // To a peer that holds a set of events, where this node's stands (`swarm::set`). #[cfg(feature = "federation")] - let heads = crate::swarm::set::stamp(state).unwrap_or(heads); + let heads = crate::swarm::set::stamp(state, _of_a_set).unwrap_or(heads); let (reaches, round_trips) = crate::swarm::reach::published_with_round_trips(state); transport::Status { heads, |
