aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/libp2p/driver.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-01 13:29:34 +0100
committertv <tv@krebsco.de>2026-11-01 13:29:34 +0100
commit400c4e845998101b94780b101a400c04d38897da (patch)
tree8b75886e6eff27c36932218ae63b8418bad65238 /src/transport/libp2p/driver.rs
parent12fbf8bf78408abbfde0ec1802f39307def4a0ee (diff)
libp2p: bump dupe grace period
Diffstat (limited to 'src/transport/libp2p/driver.rs')
-rw-r--r--src/transport/libp2p/driver.rs18
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,