From 7a6eda9ca3abcb64bd41a6b85ea56a5b3f8b0b51 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 1 Nov 2026 13:30:12 +0100 Subject: libp2p: one Book::usable for all dials --- src/transport/libp2p/mod.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/transport/libp2p/mod.rs') diff --git a/src/transport/libp2p/mod.rs b/src/transport/libp2p/mod.rs index 6c57867..6fea05a 100644 --- a/src/transport/libp2p/mod.rs +++ b/src/transport/libp2p/mod.rs @@ -49,8 +49,9 @@ //! it can be dialled, it lets the relays it picked go. //! //! With `--libp2p-ignore`, address ranges are left out (VPNs): not published, not told -//! peers by identify (`Identifying`), not offered for hole punching, not dialled, and -//! connections there refused (`Ignoring`). Ranges this node has no route to are left +//! peers by identify (`Identifying`), not offered for hole punching, not dialled by us +//! (`Book::usable`) nor by libp2p unless with an address elsewhere too, and connections +//! there refused (`Ignoring`). Ranges this node has no route to are left //! out alike, as long as it has none (`routes`): without IPv6 to the internet, peers' //! public IPv6 addresses; and with `--libp2p-internet-hosts`, its own aren't published //! then. With `--libp2p-prefer`, @@ -302,12 +303,7 @@ impl Libp2pTransport { async fn connect(&self, peer: PeerId) -> Result<()> { let addresses = { let mut book = lock(&self.book); - let mut known = book - .addresses - .get(&peer) - .map(|known| dialable(known, self.peer_id)) - .unwrap_or_default(); - known.retain(|address| !book.left_out(address)); + let known = book.usable(&peer, self.peer_id); if known.is_empty() { book.through_relays(peer, self.peer_id) } else { -- cgit v1.3.1