Skip to content

Commit

Permalink
make previous more resiliant to large jitters, small initial backoffs
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Jan 27, 2025
1 parent b597226 commit e9581c3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions spv/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,9 @@ func (s *Syncer) connectToPersistent(ctx context.Context, raddr string) error {
// Persistent peers use a backoff duration scaled to 1/5th of
// discovered candidate peers (min 5s -> 1s, max 1m30s -> 18s).
jitter := backoffJitter()
scaledBackoff := d / 5
if scaledBackoff != 0 {
scaledBackoff += jitter
scaledBackoff := d/5 + jitter
if scaledBackoff < 0 {
scaledBackoff = 0
}
connected := s.connectAndRunPeer(ctx, scaledBackoff, raddr, true)
if err := ctx.Err(); err != nil {
Expand Down

0 comments on commit e9581c3

Please sign in to comment.