Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #193 from libp2p/feat/backoff-cleanup
Browse files Browse the repository at this point in the history
don't expire backoffs until 2x backoff period
  • Loading branch information
Stebalien authored Apr 2, 2020
2 parents 1c0adc3 + b5d7068 commit 7694d47
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion swarm_dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ func (db *DialBackoff) cleanup() {
for p, e := range db.entries {
good := false
for _, backoff := range e {
if now.Before(backoff.until) {
backoffTime := BackoffBase + BackoffCoef*time.Duration(backoff.tries*backoff.tries)
if backoffTime > BackoffMax {
backoffTime = BackoffMax
}
if now.Before(backoff.until.Add(backoffTime)) {
good = true
break
}
Expand Down

0 comments on commit 7694d47

Please sign in to comment.