aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/libp2p/behaviour.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-01 20:59:18 +0100
committertv <tv@krebsco.de>2026-11-01 20:59:18 +0100
commit9626255663820b708800fffa91c5f38c33d3cf09 (patch)
tree092336879981ea3d170028ae80af34ac5a318550 /src/transport/libp2p/behaviour.rs
parentbf88eb98173758691b3e8cea65a6ab8a90d5ca65 (diff)
libp2p: idle timeout follows keepalive
Diffstat (limited to 'src/transport/libp2p/behaviour.rs')
-rw-r--r--src/transport/libp2p/behaviour.rs6
1 files changed, 5 insertions, 1 deletions
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