aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/peer/inbound.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm/peer/inbound.rs')
-rw-r--r--src/swarm/peer/inbound.rs22
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