From 9626255663820b708800fffa91c5f38c33d3cf09 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 1 Nov 2026 20:59:18 +0100 Subject: libp2p: idle timeout follows keepalive --- src/transport/libp2p/behaviour.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/transport/libp2p/behaviour.rs') diff --git a/src/transport/libp2p/behaviour.rs b/src/transport/libp2p/behaviour.rs index 18d8011..0b9be6b 100644 --- a/src/transport/libp2p/behaviour.rs +++ b/src/transport/libp2p/behaviour.rs @@ -188,6 +188,8 @@ pub(super) struct Features { pub(super) mdns: bool, pub(super) upnp: bool, pub(super) public: bool, + /// How long a connection may idle (`idle_timeout`). + pub(super) idle_timeout: Duration, } impl Features { @@ -197,6 +199,7 @@ impl Features { mdns: config.mdns, upnp: config.upnp, public: config.public, + idle_timeout: idle_timeout(config.keepalive), } } } @@ -228,6 +231,7 @@ impl Behaviour { mdns, upnp, public, + idle_timeout: _, } = features; let peer_id = key.public().to_peer_id(); let kad = public.then(|| { @@ -335,7 +339,7 @@ pub(super) fn swarm_config( features: Features, ) -> ::libp2p::swarm::Config { let config = config - .with_idle_connection_timeout(IDLE_TIMEOUT) + .with_idle_connection_timeout(features.idle_timeout) .with_dial_concurrency_factor(DIAL_CONCURRENCY); if features.public { config -- cgit v1.3.1