aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/mod.rs')
-rw-r--r--src/transport/mod.rs40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index e366f72..ee63988 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -254,6 +254,21 @@ pub(crate) enum ParsedMessage {
Disconnect(NeighbourAnswer),
/// Changes the sender refused, of those the recipient brought (`swarm::refusals`).
Refusals(RefusalsMessage),
+ /// What the sender's build speaks and knows, in a layout no build changes
+ /// (`wire::SPEAKS`, `swarm::speaking`).
+ Speaks(Speaks),
+}
+
+/// SPEAKS: the wire versions the sender speaks, the oldest and the newest, and the
+/// newest revision of the federation it knows, by ID, where it is built with the
+/// federation. Sent with every handshake, and ahead of every WHO and ME
+/// (`transport::identity`), in a layout no build changes (`wire::SPEAKS`): a build that
+/// doesn't know it ignores it, as a message of another wire version.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub(crate) struct Speaks {
+ pub(crate) oldest: u8,
+ pub(crate) newest: u8,
+ pub(crate) revision: Option<[u8; 32]>,
}
/// REFUSALS: changes the sender refused by the swarm's rules (`access::screen`), of
@@ -417,6 +432,7 @@ pub(crate) enum MessageKind {
NeighbourReply,
Disconnect,
Refusals,
+ Speaks,
}
impl ParsedMessage {
@@ -440,6 +456,7 @@ impl ParsedMessage {
ParsedMessage::NeighbourReply(_) => MessageKind::NeighbourReply,
ParsedMessage::Disconnect(_) => MessageKind::Disconnect,
ParsedMessage::Refusals(_) => MessageKind::Refusals,
+ ParsedMessage::Speaks(_) => MessageKind::Speaks,
}
}
@@ -469,7 +486,8 @@ impl ParsedMessage {
ParsedMessage::Who(_)
| ParsedMessage::Me(_)
| ParsedMessage::Ping(_)
- | ParsedMessage::Pong { .. } => None,
+ | ParsedMessage::Pong { .. }
+ | ParsedMessage::Speaks(_) => None,
}
}
}
@@ -566,6 +584,9 @@ pub(crate) struct HelloRequest {
/// a joining node takes as the root, where those it hears agree.
#[serde(with = "serde_bytes")]
pub(crate) root: Option<Vec<u8>>,
+ /// The party the sender is of, in a swarm holding a store (`--store-party`): nodes of
+ /// one sync with the nodes its parties list, each as its party's. None elsewhere.
+ pub(crate) party: Option<String>,
}
/// A peer a HELLO_REPLY lists: who it is, and where the sender reaches it.
@@ -654,6 +675,8 @@ pub(crate) struct HelloReply {
/// As `HelloRequest::root`.
#[serde(with = "serde_bytes")]
pub(crate) root: Option<Vec<u8>>,
+ /// As `HelloRequest::party`.
+ pub(crate) party: Option<String>,
}
/// Bytes shown as lowercase hex, e.g. run IDs in logs.
@@ -688,6 +711,7 @@ impl std::fmt::Debug for HelloRequest {
.field("run_id", &Hex(&self.run_id))
.field("handshake", &self.handshake)
.field("root", &self.root.as_deref().map(Hex))
+ .field("party", &self.party)
.finish()
}
}
@@ -705,6 +729,7 @@ impl std::fmt::Debug for HelloReply {
.field("away_ms", &self.away_ms)
.field("sender_run_id", &Hex(&self.sender_run_id))
.field("root", &self.root.as_deref().map(Hex))
+ .field("party", &self.party)
.finish()
}
}
@@ -1174,7 +1199,18 @@ pub(crate) trait Transport: Send + Sync {
/// identity, as `local_id` gives it on that node.
async fn resolve_seed(&self, seed: &str) -> Result<String>;
- fn encode(&self, peer: &str, message: &ParsedMessage) -> Result<EncodedMessage>;
+ /// `message` to `peer` in wire `version`, one this build speaks (`wire::OLDEST..=
+ /// wire::VERSION`). The identity layer writes to each node in the newest version both
+ /// speak, whatever is asked (`Paths::version_at`).
+ fn encode_in(&self, peer: &str, message: &ParsedMessage, version: u8)
+ -> Result<EncodedMessage>;
+
+ /// `message` to `peer` in the newest wire version; under the identity layer, in the one
+ /// `peer` speaks.
+ fn encode(&self, peer: &str, message: &ParsedMessage) -> Result<EncodedMessage> {
+ self.encode_in(peer, message, wire::VERSION)
+ }
+
async fn send_encoded(&self, message: &EncodedMessage) -> Result<()>;
/// Sends an outbound message payload to a targeted peer on a specific topic.