diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 6bcdc66106d..875fd7a3be6 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.44.0 - unreleased +- Remove deprecated `keep_alive_timeout` in `OneShotHandlerConfig`. + See [PR 4677](https://github.com/libp2p/rust-libp2p/pull/4677). ## 0.43.6 diff --git a/swarm/src/handler/one_shot.rs b/swarm/src/handler/one_shot.rs index 473aa50798c..7f422cfa7d0 100644 --- a/swarm/src/handler/one_shot.rs +++ b/swarm/src/handler/one_shot.rs @@ -24,7 +24,6 @@ use crate::handler::{ SubstreamProtocol, }; use crate::upgrade::{InboundUpgradeSend, OutboundUpgradeSend}; -use instant::Instant; use smallvec::SmallVec; use std::{error, fmt::Debug, task::Context, task::Poll, time::Duration}; @@ -176,9 +175,8 @@ where } else { self.dial_queue.shrink_to_fit(); - #[allow(deprecated)] if self.dial_negotiated == 0 && self.keep_alive.is_yes() { - self.keep_alive = KeepAlive::Until(Instant::now() + self.config.keep_alive_timeout); + self.keep_alive = KeepAlive::No; } } @@ -199,13 +197,6 @@ where protocol: out, .. }) => { - // If we're shutting down the connection for inactivity, reset the timeout. - #[allow(deprecated)] - if !self.keep_alive.is_yes() { - self.keep_alive = - KeepAlive::Until(Instant::now() + self.config.keep_alive_timeout); - } - self.events_out.push(out.into()); } ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { @@ -232,11 +223,6 @@ where /// Configuration parameters for the `OneShotHandler` #[derive(Debug)] pub struct OneShotHandlerConfig { - /// Keep-alive timeout for idle connections. - #[deprecated( - note = "Set a global idle connection timeout via `SwarmBuilder::idle_connection_timeout` instead." - )] - pub keep_alive_timeout: Duration, /// Timeout for outbound substream upgrades. pub outbound_substream_timeout: Duration, /// Maximum number of concurrent outbound substreams being opened. @@ -247,7 +233,6 @@ impl Default for OneShotHandlerConfig { #[allow(deprecated)] fn default() -> Self { OneShotHandlerConfig { - keep_alive_timeout: Duration::from_secs(10), outbound_substream_timeout: Duration::from_secs(10), max_dial_negotiated: 8, } @@ -277,9 +262,6 @@ mod tests { } })); - assert!(matches!( - handler.connection_keep_alive(), - KeepAlive::Until(_) - )); + assert!(matches!(handler.connection_keep_alive(), KeepAlive::No)); } }