summaryrefslogtreecommitdiffstats
path: root/src/transport/paths.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/paths.rs')
-rw-r--r--src/transport/paths.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/transport/paths.rs b/src/transport/paths.rs
index ba16794..e966839 100644
--- a/src/transport/paths.rs
+++ b/src/transport/paths.rs
@@ -449,20 +449,23 @@ impl Paths {
self.located(infos)
}
- /// `infos` with where each path goes, where the transport knows
- /// (`Transport::location`); asked outside the table's lock.
+ /// `infos` with where each path goes (`located`); asked outside the table's lock.
fn located(&self, mut infos: Vec<PathInfo>) -> Vec<PathInfo> {
for info in &mut infos {
- if let Some((link, location)) = self
- .split(&info.address)
- .and_then(|(link, target)| Some((link, link.inner.location(&target)?)))
- {
- info.address = link.address(&location);
- }
+ info.address = self.location(&info.address);
}
infos
}
+ /// `address` (as paths keep it) as where it goes now, where the transport knows
+ /// more (`Transport::location`: libp2p, its connection's remote address); else
+ /// `address` itself. For showing: paths go by `address`.
+ pub(crate) fn location(&self, address: &str) -> String {
+ self.split(address)
+ .and_then(|(link, target)| Some(link.address(&link.inner.location(&target)?)))
+ .unwrap_or_else(|| address.to_owned())
+ }
+
/// Whether `address` is one of ours.
pub(crate) fn is_own(&self, address: &str) -> bool {
self.links.iter().any(|link| link.own_address() == address)