Skip to content

Commit 4bc0711

Browse files
cuishuangrolandshoemaker
authored andcommitted
acme: use built-in max/min to simplify the code
Change-Id: I6ba8d07b9e53b01f25f4c1c8eac629aaa47de3a1 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/664836 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
1 parent c96bba2 commit 4bc0711

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

acme/http.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (c *Client) retryTimer() *retryTimer {
6666
// The n argument is always bounded between 1 and 30.
6767
// The returned value is always greater than 0.
6868
func defaultBackoff(n int, r *http.Request, res *http.Response) time.Duration {
69-
const max = 10 * time.Second
69+
const maxVal = 10 * time.Second
7070
var jitter time.Duration
7171
if x, err := rand.Int(rand.Reader, big.NewInt(1000)); err == nil {
7272
// Set the minimum to 1ms to avoid a case where
@@ -86,10 +86,7 @@ func defaultBackoff(n int, r *http.Request, res *http.Response) time.Duration {
8686
n = 30
8787
}
8888
d := time.Duration(1<<uint(n-1))*time.Second + jitter
89-
if d > max {
90-
return max
91-
}
92-
return d
89+
return min(d, maxVal)
9390
}
9491

9592
// retryAfter parses a Retry-After HTTP header value,

0 commit comments

Comments
 (0)