From ec862a35e867c118dbab237e72057a433bc968d7 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Oct 2026 02:07:04 +0100 Subject: 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. --- src/transport/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/transport/mod.rs') 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 { + 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 { + 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 { -- cgit v1.3.1