diff --git a/protocols/identify/CHANGELOG.md b/protocols/identify/CHANGELOG.md index d05e63a5..69f26e44 100644 --- a/protocols/identify/CHANGELOG.md +++ b/protocols/identify/CHANGELOG.md @@ -4,8 +4,12 @@ - Raise MSRV to 1.65. See [PR 3715]. +- Reduce the initial delay before running the identify protocol to 0 and make the option deprecated. + See [PR 3545]. + [PR 3698]: https://github.com/libp2p/rust-libp2p/pull/3698 [PR 3715]: https://github.com/libp2p/rust-libp2p/pull/3715 +[PR 3545]: https://github.com/libp2p/rust-libp2p/pull/3545 ## 0.42.2 diff --git a/protocols/identify/src/behaviour.rs b/protocols/identify/src/behaviour.rs index 08d06814..6dcea9c1 100644 --- a/protocols/identify/src/behaviour.rs +++ b/protocols/identify/src/behaviour.rs @@ -88,7 +88,10 @@ pub struct Config { /// The initial delay before the first identification request /// is sent to a remote on a newly established connection. /// - /// Defaults to 500ms. + /// Defaults to 0ms. + #[deprecated(note = "The `initial_delay` is no longer necessary and will be + completely removed since a remote should be able to instantly + answer to an identify request")] pub initial_delay: Duration, /// The interval at which identification requests are sent to /// the remote on established connections after the first request, @@ -117,12 +120,13 @@ pub struct Config { impl Config { /// Creates a new configuration for the identify [`Behaviour`] that /// advertises the given protocol version and public key. + #[allow(deprecated)] pub fn new(protocol_version: String, local_public_key: PublicKey) -> Self { Self { protocol_version, agent_version: format!("rust-libp2p/{}", env!("CARGO_PKG_VERSION")), local_public_key, - initial_delay: Duration::from_millis(500), + initial_delay: Duration::from_millis(0), interval: Duration::from_secs(5 * 60), push_listen_addr_updates: false, cache_size: 100, @@ -137,6 +141,10 @@ impl Config { /// Configures the initial delay before the first identification /// request is sent on a newly established connection to a peer. + #[deprecated(note = "The `initial_delay` is no longer necessary and will be + completely removed since a remote should be able to instantly + answer to an identify request thus also this setter will be removed")] + #[allow(deprecated)] pub fn with_initial_delay(mut self, d: Duration) -> Self { self.initial_delay = d; self @@ -239,6 +247,7 @@ impl NetworkBehaviour for Behaviour { type ConnectionHandler = Handler; type OutEvent = Event; + #[allow(deprecated)] fn handle_established_inbound_connection( &mut self, _: ConnectionId, @@ -257,6 +266,7 @@ impl NetworkBehaviour for Behaviour { )) } + #[allow(deprecated)] fn handle_established_outbound_connection( &mut self, _: ConnectionId, @@ -737,6 +747,7 @@ mod tests { let mut swarm1 = { let (pubkey, transport) = transport(); + #[allow(deprecated)] let protocol = Behaviour::new( Config::new("a".to_string(), pubkey.clone()) // `swarm1` will set `KeepAlive::No` once it identified `swarm2` and thus