diff options
Diffstat (limited to 'src/swarm/peer')
| -rw-r--r-- | src/swarm/peer/handshake.rs | 2 | ||||
| -rw-r--r-- | src/swarm/peer/inbound.rs | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/swarm/peer/handshake.rs b/src/swarm/peer/handshake.rs index d3f6b99..2e5a315 100644 --- a/src/swarm/peer/handshake.rs +++ b/src/swarm/peer/handshake.rs @@ -144,6 +144,7 @@ async fn transmit_hello(state: &AppState, peer: &str) -> Result<()> { .await .map(|root| root.0.to_vec()), party: party(state), + kind: crate::document::KIND.to_owned(), }), ) .await; @@ -254,6 +255,7 @@ pub(super) async fn send_hello_reply( .await .map(|root| root.0.to_vec()), party: party(state), + kind: crate::document::KIND.to_owned(), }; debug!(to = %peer, ready, "Sending HELLO_REPLY"); diff --git a/src/swarm/peer/inbound.rs b/src/swarm/peer/inbound.rs index e23ec14..a558ded 100644 --- a/src/swarm/peer/inbound.rs +++ b/src/swarm/peer/inbound.rs @@ -108,6 +108,20 @@ pub(crate) async fn handle_message( return Ok(()); } + // Its document's kind: another than ours has nothing ours takes. + let kind = match &message { + ParsedMessage::Hello(hello) => Some(&hello.kind), + ParsedMessage::HelloReply(reply) => Some(&reply.kind), + _ => None, + }; + if let Some(theirs) = kind.filter(|kind| *kind != crate::document::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", + crate::document::KIND + ); + } + // The root its document starts from: another than ours, of our epoch, is another // history; what a joiner takes as its root follows those named (`swarm::roots`). match &message { |
