diff options
| author | tv <tv@krebsco.de> | 2026-11-30 14:33:09 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-30 14:33:09 +0000 |
| commit | 8e97bcfa65e92da21df912cc5e19cf18027b82b8 (patch) | |
| tree | c0d5b42766e79b2215cb65a0214fc25607d73d5f /src/swarm/peer/inbound.rs | |
| parent | 362633603e9fc1912fd35807da5653dc1273a5be (diff) | |
swarm: a node whose store a set of events carries
Such a node (Holding::carrying) holds an Automerge document with
nothing in it, which nothing passes on, and its set is its document:
* swarm::set passes the set on. Where it stands goes in the node's
STATUSes as another kind's stamp, and a peer's is given to the set;
what the set says besides goes as a SYNC's body; what the set took, of
a peer or of the node itself, goes on to the node's other neighbours.
What compares stamps for an Automerge document's sake is handed the
node's own, and finds nothing to do; the Automerge sync isn't begun.
* The node writes its own entry (AppState::mutate_set): what writes
protocol data through a view writes to the members' entries as a
tree, and what the node's own reads as after is put as its next
entry, signed and passed on. Anything else is refused, and so is a
write to an Automerge document as such.
* An event the node writes (held::write) is offered to the set and
passed on; a set lacks nothing of its store to put again.
* The node's swarm is its store's, said at its start.
A simulation: three such nodes of two parties register, and each
holds the others' entries; events put on two of them reach all three,
and they come to stand alike, the documents they hold beside empty.
Diffstat (limited to 'src/swarm/peer/inbound.rs')
| -rw-r--r-- | src/swarm/peer/inbound.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/swarm/peer/inbound.rs b/src/swarm/peer/inbound.rs index dbf1a2e..0354356 100644 --- a/src/swarm/peer/inbound.rs +++ b/src/swarm/peer/inbound.rs @@ -218,6 +218,15 @@ pub(crate) async fn handle_message( .map_err(|error| anyhow!("Failed to notify sync worker: {error}"))?; } transport::ParsedMessage::Sync(envelope) => { + // Of a set of events, where one carries this node's store: its own to + // take (`swarm::set`), and nothing of an Automerge document's. + #[cfg(feature = "federation")] + if state.of_a_set() { + if let transport::SyncBody::Kind(body) = envelope.body { + crate::swarm::set::received(state, &peer, body).await; + } + return Ok(()); + } if reactivated { ensure_handshake(state, &peer).await; } @@ -251,6 +260,8 @@ pub(crate) async fn handle_message( crate::swarm::blob::handle(state, &peer, blob).await; } transport::ParsedMessage::Status(remote) => { + #[cfg(feature = "federation")] + let remote = crate::swarm::set::heard_status(state, &peer, remote); // An announcement is no keepalive; it is answered only if we lack some of the // heads it announced (`relay::lacks`), so the announcer learns what we have // that it lacks while we pull. Having all of them, we are as far or further, @@ -290,6 +301,8 @@ pub(crate) async fn handle_message( } } transport::ParsedMessage::StatusReply(remote) => { + #[cfg(feature = "federation")] + let remote = crate::swarm::set::heard_status(state, &peer, remote); // An answer to our slow round's announcement: a tree missed. let announced = peer_state.lock().await.slow_announced_at.take(); if let Some(at) = announced { |
