diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index f83c554d333..8741f8b4cb4 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -5,6 +5,9 @@ - Remove `Rpc` from the public API. See [PR 6091](https://github.com/libp2p/rust-libp2p/pull/6091) +- Fix `unsubscribe_backoff` expecting number of seconds instead of `Duration` + See [PR 6124](https://github.com/libp2p/rust-libp2p/pull/6124) + ## 0.49.2 - Relax `Behaviour::with_metrics` requirements, do not require DataTransform and TopicSubscriptionFilter to also impl Default diff --git a/protocols/gossipsub/src/behaviour/tests.rs b/protocols/gossipsub/src/behaviour/tests.rs index 85aead47911..04c86bd3df4 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -2185,7 +2185,7 @@ fn test_unsubscribe_backoff() { .backoff_slack(1) // ensure a prune_backoff > unsubscribe_backoff .prune_backoff(Duration::from_secs(5)) - .unsubscribe_backoff(1) + .unsubscribe_backoff(Duration::from_secs(1)) .heartbeat_interval(HEARTBEAT_INTERVAL) .build() .unwrap(); diff --git a/protocols/gossipsub/src/config.rs b/protocols/gossipsub/src/config.rs index ec8b6cac3a4..992d5fafbd9 100644 --- a/protocols/gossipsub/src/config.rs +++ b/protocols/gossipsub/src/config.rs @@ -858,8 +858,8 @@ impl ConfigBuilder { /// This is how long to wait before resubscribing to the topic. A short backoff period in case /// of an unsubscribe event allows reaching a healthy mesh in a more timely manner. The default /// is 10 seconds. - pub fn unsubscribe_backoff(&mut self, unsubscribe_backoff: u64) -> &mut Self { - self.config.unsubscribe_backoff = Duration::from_secs(unsubscribe_backoff); + pub fn unsubscribe_backoff(&mut self, unsubscribe_backoff: Duration) -> &mut Self { + self.config.unsubscribe_backoff = unsubscribe_backoff; self }