From 24327be7e09c20a9820eac61ba3ac60fb7bdb424 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Oct 2026 02:18:01 +0100 Subject: measure paths --- src/transport/identity.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/transport/identity.rs') diff --git a/src/transport/identity.rs b/src/transport/identity.rs index dd3950b..5857fb0 100644 --- a/src/transport/identity.rs +++ b/src/transport/identity.rs @@ -95,7 +95,7 @@ pub(crate) struct IdentityTransport { } struct Shared { - paths: Paths, + paths: Arc, key: Arc, node_id: String, /// WHO and ME are counted here, under the address (`traffic`). @@ -214,11 +214,12 @@ impl IdentityTransport { traffic: Arc, ) -> Self { let node_id = config.key.id(); - let paths = Paths::new( + let paths = Arc::new(Paths::new( std::iter::once((config.scheme, transport)) .chain(config.more) .collect(), - ); + Some(Arc::clone(&traffic)), + )); Self { shared: Arc::new(Shared { paths, @@ -443,20 +444,20 @@ impl Transport for IdentityTransport { self.shared.paths.transports() } - /// The address `encode` picks, and the transport's connection there. + /// The address `encode` picks, the transport's connection there, and every path + /// to `peer` as paths measures it, best first. fn destination(&self, peer: &str) -> Option { - let address = self.shared.destination(peer)?; - let proven = self - .shared - .lock() - .proven - .get(peer) - .is_some_and(|addresses| addresses.contains(&address)); + let proven = self.shared.proven_at(peer); + let (address, is_proven) = match proven.first() { + Some(address) => (address.clone(), true), + None => (self.shared.hinted_at(peer).into_iter().next()?, false), + }; let connection = self.shared.paths.connection(&address); Some(Destination { address, - proven, + proven: is_proven, connection, + paths: self.shared.paths.info(&proven), }) } -- cgit v1.3.1