summaryrefslogtreecommitdiffstats
path: root/src/transport/mod.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-27 01:01:51 +0100
committertv <tv@krebsco.de>2026-10-27 01:01:51 +0100
commit5fd686dcd8ddfbdf276c044e5acf03f744e03193 (patch)
treea4f04328c8a2de0a50d3af3c9a8a92bfe2b118a2 /src/transport/mod.rs
parentb90cfd1fde4e1c00d03e44976753d0044b273bda (diff)
introduce addresses
Diffstat (limited to 'src/transport/mod.rs')
-rw-r--r--src/transport/mod.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index 61b1f4b..29c48d6 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -297,10 +297,18 @@ pub(crate) struct HelloRequest {
pub(crate) handshake: u32,
}
+/// A peer a HELLO_REPLY lists: who it is, and where the sender reaches it.
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub(crate) struct ListedPeer {
+ pub(crate) id: String,
+ /// As `Transport::addresses_of` gives them; hints for the recipient.
+ pub(crate) addresses: Vec<String>,
+}
+
#[derive(Clone, Serialize, Deserialize)]
pub(crate) struct HelloReply {
pub(crate) swarm_id: String,
- pub(crate) peers: Vec<String>,
+ pub(crate) peers: Vec<ListedPeer>,
#[serde(with = "crate::transport::wire::codec::epoch")]
pub(crate) epoch: Epoch,
/// See `SyncEnvelope::epoch_seq`.
@@ -490,6 +498,26 @@ pub(crate) trait Transport: Send + Sync {
/// a message sent is delivered or lost for good.
fn delivery_limit(&self) -> std::time::Duration;
+ /// Where this node can be reached, as addresses other nodes can use: published in
+ /// the member list (`swarm::members`). By default its identity, for a transport
+ /// whose identities are addresses (Mycelium: a public key).
+ fn local_addresses(&self) -> Vec<String> {
+ vec![self.local_id().to_owned()]
+ }
+
+ /// Where `peer` can be reached, as far as this node knows: passed on to others (in
+ /// a HELLO_REPLY). By default its identity, as for `local_addresses`.
+ fn addresses_of(&self, peer: &str) -> Vec<String> {
+ vec![peer.to_owned()]
+ }
+
+ /// Where others say `peer` can be reached (the member list, a HELLO_REPLY): hints,
+ /// to be checked before they are relied on. By default nothing to learn, as for
+ /// `local_addresses`.
+ fn learn_addresses(&self, peer: &str, addresses: &[String]) {
+ let _ = (peer, addresses);
+ }
+
/// Resolves a seed (anything that leads to a node, e.g. an address) to that node's
/// identity, as `local_id` gives it on that node.
async fn resolve_seed(&self, seed: &str) -> Result<String>;