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
commitfec2900523cba5a70b7f0f67f2b132c7a655a926 (patch)
tree60f2a4e0ab6dbafe572154dc1cd1cd9ebfd1cc7a /src/transport/libp2p/driver.rs
parent497eab7136b9d35101f4a5ffa81797efb85da390 (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,