mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
fix edge case on ticker
This commit is contained in:
parent
844603ea4e
commit
a7e3222023
1 changed files with 8 additions and 1 deletions
|
|
@ -33,6 +33,7 @@ var (
|
|||
const (
|
||||
heimdallAPIBodyLimit = 128 * 1024 * 1024 // 128 MB
|
||||
stateFetchLimit = 50
|
||||
retryCall = 5 * time.Second
|
||||
)
|
||||
|
||||
type StateSyncEventsResponse struct {
|
||||
|
|
@ -292,7 +293,13 @@ func FetchWithRetry[T any](ctx context.Context, client http.Client, url *url.URL
|
|||
log.Warn("an error while trying fetching from Heimdall", "path", url.Path, "attempt", attempt, "error", err)
|
||||
|
||||
// create a new ticker for retrying the request
|
||||
ticker := time.NewTicker(client.Timeout)
|
||||
var ticker *time.Ticker
|
||||
if client.Timeout != 0 {
|
||||
ticker = time.NewTicker(client.Timeout)
|
||||
} else {
|
||||
// only reach here when HeimdallClient is HeimdallGRPCClient or HeimdallAppClient
|
||||
ticker = time.NewTicker(retryCall)
|
||||
}
|
||||
defer ticker.Stop()
|
||||
|
||||
const logEach = 5
|
||||
|
|
|
|||
Loading…
Reference in a new issue