aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcuishuang <imcusg@gmail.com>2025-04-11 18:15:39 +0800
committerRoland Shoemaker <roland@golang.org>2025-04-11 09:06:14 -0700
commit4bc0711281828327e78c10b8c280675e47e6cc23 (patch)
tree8eaaa45198379cebd99885821badd8b45e2b91df
parentc96bba2ced58241e913463bed27fdb1f43ef21f4 (diff)
downloadgo-x-crypto-4bc0711281828327e78c10b8c280675e47e6cc23.tar.xz
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>
-rw-r--r--acme/http.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/acme/http.go b/acme/http.go
index d92ff23..8f29df5 100644
--- a/acme/http.go
+++ b/acme/http.go
@@ -66,7 +66,7 @@ func (c *Client) retryTimer() *retryTimer {
// The n argument is always bounded between 1 and 30.
// The returned value is always greater than 0.
func defaultBackoff(n int, r *http.Request, res *http.Response) time.Duration {
- const max = 10 * time.Second
+ const maxVal = 10 * time.Second
var jitter time.Duration
if x, err := rand.Int(rand.Reader, big.NewInt(1000)); err == nil {
// 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 {
n = 30
}
d := time.Duration(1<<uint(n-1))*time.Second + jitter
- if d > max {
- return max
- }
- return d
+ return min(d, maxVal)
}
// retryAfter parses a Retry-After HTTP header value,