Skip to content

Commit 2207ac4

Browse files
committed
feat: cap the backoff for sending events to timeout * 3
1 parent bb7e4eb commit 2207ac4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

testnet/stacks-node/src/event_dispatcher.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ impl EventObserver {
429429
.unwrap_or(PeerHost::DNS(host.to_string(), port));
430430

431431
let mut backoff = Duration::from_millis(100);
432+
let max_backoff = timeout.saturating_mul(3);
432433
loop {
433434
let mut request = StacksHttpRequest::new_for_peer(
434435
peerhost.clone(),
@@ -472,7 +473,7 @@ impl EventObserver {
472473
}
473474

474475
sleep(backoff);
475-
backoff *= 2;
476+
backoff = std::cmp::min(backoff.saturating_mul(2), max_backoff);
476477
}
477478
}
478479

0 commit comments

Comments
 (0)