aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/paths.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/paths.rs')
-rw-r--r--src/transport/paths.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/transport/paths.rs b/src/transport/paths.rs
index 658f681..ce19fd4 100644
--- a/src/transport/paths.rs
+++ b/src/transport/paths.rs
@@ -620,17 +620,30 @@ impl Paths {
.unwrap_or_default()
}
- /// Each transport's (`Transport::local_addresses`), with its scheme.
+ /// Each transport's (`Transport::local_addresses`), with its scheme: taken in turns,
+ /// each transport's first in the configured order, then each one's second, and so on,
+ /// so a list cut short (`members::MAX_ADDRESSES`) still has every transport's best.
pub(crate) fn local_addresses(&self) -> Vec<String> {
- self.links
+ let mut each: Vec<std::vec::IntoIter<String>> = self
+ .links
.iter()
- .flat_map(|link| {
+ .map(|link| {
link.inner
.local_addresses()
.into_iter()
.map(|target| link.address(&target))
+ .collect::<Vec<_>>()
+ .into_iter()
})
- .collect()
+ .collect();
+ let mut addresses = Vec::new();
+ loop {
+ let before = addresses.len();
+ addresses.extend(each.iter_mut().filter_map(Iterator::next));
+ if addresses.len() == before {
+ return addresses;
+ }
+ }
}
/// The schemes of the transports, in order of preference.