diff options
Diffstat (limited to 'src/transport/libp2p/driver.rs')
| -rw-r--r-- | src/transport/libp2p/driver.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/transport/libp2p/driver.rs b/src/transport/libp2p/driver.rs index b8c8c37..c89a784 100644 --- a/src/transport/libp2p/driver.rs +++ b/src/transport/libp2p/driver.rs @@ -208,9 +208,21 @@ pub(super) async fn run( book.upgrades.remove(&peer_id); book.punching.remove(&peer_id); } - if relaying.local < peer_id - && book.connections.values().filter(|(connected, _, _)| *connected == peer_id).count() > 1 - { + let to_peer: Vec<ConnectionId> = book + .connections + .iter() + .filter(|(_, (connected, _, _))| *connected == peer_id) + .map(|(id, _)| *id) + .collect(); + if to_peer.len() > 1 { + // A new path to compare: each is judged by its round trips + // from now on, not an old one by its best over hours + // (`Book::ranked`). + for connection in &to_peer { + book.rtts.remove(connection); + } + } + if relaying.local < peer_id && to_peer.len() > 1 { // Only through relays: maybe a punch under way. let grace = match book.connection(&peer_id) { Some(Connection::Relayed) => PUNCH_GRACE, |
