Skip to content

Commit 172bbed

Browse files
fix(gossipsub): Changed unsubscribe_backoff to expect Duration
Gossipsub config back-off takes a duration as a number of seconds instead of `std::time::Duration`, this PR fixes that. Fixes #6120 Pull-Request: #6124.
1 parent 3b518c4 commit 172bbed

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

protocols/gossipsub/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- Remove `Rpc` from the public API.
66
See [PR 6091](https://github.com/libp2p/rust-libp2p/pull/6091)
77

8+
- Fix `unsubscribe_backoff` expecting number of seconds instead of `Duration`
9+
See [PR 6124](https://github.com/libp2p/rust-libp2p/pull/6124)
10+
811
## 0.49.2
912

1013
- Relax `Behaviour::with_metrics` requirements, do not require DataTransform and TopicSubscriptionFilter to also impl Default

protocols/gossipsub/src/behaviour/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,7 @@ fn test_unsubscribe_backoff() {
21852185
.backoff_slack(1)
21862186
// ensure a prune_backoff > unsubscribe_backoff
21872187
.prune_backoff(Duration::from_secs(5))
2188-
.unsubscribe_backoff(1)
2188+
.unsubscribe_backoff(Duration::from_secs(1))
21892189
.heartbeat_interval(HEARTBEAT_INTERVAL)
21902190
.build()
21912191
.unwrap();

protocols/gossipsub/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,8 +858,8 @@ impl ConfigBuilder {
858858
/// This is how long to wait before resubscribing to the topic. A short backoff period in case
859859
/// of an unsubscribe event allows reaching a healthy mesh in a more timely manner. The default
860860
/// is 10 seconds.
861-
pub fn unsubscribe_backoff(&mut self, unsubscribe_backoff: u64) -> &mut Self {
862-
self.config.unsubscribe_backoff = Duration::from_secs(unsubscribe_backoff);
861+
pub fn unsubscribe_backoff(&mut self, unsubscribe_backoff: Duration) -> &mut Self {
862+
self.config.unsubscribe_backoff = unsubscribe_backoff;
863863
self
864864
}
865865

0 commit comments

Comments
 (0)