summaryrefslogtreecommitdiffstats
path: root/src/transport/mod.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-27 02:07:04 +0100
committertv <tv@krebsco.de>2026-10-27 02:07:04 +0100
commitec862a35e867c118dbab237e72057a433bc968d7 (patch)
treec39c05cc098bba2a586f660b6c3f319a43568b1c /src/transport/mod.rs
parentb56535ba5d236a96598d8156e3534932271acf54 (diff)
introduce locations
This prepares the identity layer for transports where an identity alone doesn't say where a node is. The identity layer keeps identities in its books and publishes locations. For Mycelium and the simulator both methods default to the identity, so nothing changes there.
Diffstat (limited to 'src/transport/mod.rs')
-rw-r--r--src/transport/mod.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index cbbef45..58e71d8 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -531,6 +531,22 @@ pub(crate) trait Transport: Send + Sync {
vec![self.local_id().to_owned()]
}
+ /// For a transport under the identity layer: the transport identity at `target`, an
+ /// address of this transport without its scheme, noting where it is if `target` says
+ /// more than who (as a libp2p multiaddr ending in the peer ID does). None if
+ /// `target` isn't one of this transport's. By default `target` itself, for a
+ /// transport whose identities are addresses.
+ fn locate(&self, target: &str) -> Option<String> {
+ self.is_peer_id(target).then(|| target.to_owned())
+ }
+
+ /// For a transport under the identity layer: where the node with transport identity
+ /// `target` is, as addresses others can use (`locate` reads them). By default
+ /// `target` itself, as for `locate`.
+ fn locations(&self, target: &str) -> Vec<String> {
+ vec![target.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> {