diff options
| author | tv <tv@krebsco.de> | 2026-11-30 17:39:23 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-30 17:39:23 +0000 |
| commit | 93defc68f9b99da921f4746e91e5cee9e6e3f1b9 (patch) | |
| tree | b38f06c630c044f2c608ca321b1b73517bae5ea6 /src/swarm/peer/inbound.rs | |
| parent | 6ca6a97f5f9864c971c979c2c1758071a88635d0 (diff) | |
swarm: a node says to each peer the kind that peer holds, of those it holds
A node holds one kind of document, or, to come, its store in both
(Holding::kinds, of_both). The kind a peer's handshakes say is kept with
the peer, where the node holds it too, and is what the node says to it
in turn; to a peer that said none yet, a node of more than one kind
says each in turn, HELLO by HELLO, until one is answered. A node of one
kind says and takes that one, as before.
Diffstat (limited to 'src/swarm/peer/inbound.rs')
| -rw-r--r-- | src/swarm/peer/inbound.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/swarm/peer/inbound.rs b/src/swarm/peer/inbound.rs index 0354356..35d67c8 100644 --- a/src/swarm/peer/inbound.rs +++ b/src/swarm/peer/inbound.rs @@ -114,12 +114,22 @@ pub(crate) async fn handle_message( ParsedMessage::HelloReply(reply) => Some(&reply.kind), _ => None, }; - if let Some(theirs) = kind.filter(|kind| *kind != state.kind()) { - anyhow::bail!( - "{peer} holds a document of another kind ({theirs}; this node's is {}): they sync \ - nothing; a release that knows the kind does", - state.kind() - ); + if let Some(theirs) = kind { + let Some(held) = state.kinds().iter().find(|held| *held == theirs) else { + anyhow::bail!( + "{peer} holds a document of another kind ({theirs}; this node's is {}): they \ + sync nothing; a release that knows the kind does", + state.kinds().join(" and ") + ); + }; + // Of the kinds this node holds, the one the peer holds: what it is told in + // turn, and passed on. + state + .get_or_create_peer_state(&peer) + .await + .lock() + .await + .kind = Some(held); } // The root its document starts from: another than ours, of our epoch, is another |
