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
commit83b2f9efbbcedea3297fea6754ea4a0e7ac6b3e0 (patch)
treeb8dad406e79a23f8bf9ada3cdfb7da345c2ccba6 /src/transport/libp2p/behaviour.rs
parent151d0a71ac8aef450c90c243966fb64aa63a63c7 (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