diff --git a/consensus/bor/rest.go b/consensus/bor/rest.go index 6460b75a3c..3ef531de18 100644 --- a/consensus/bor/rest.go +++ b/consensus/bor/rest.go @@ -99,11 +99,22 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo u.Path = rawPath u.RawQuery = rawQuery + // attempt counter + attempt := 1 + + // request data once + res, err := h.internalFetch(u) + if err == nil && res != nil { + return res, nil + } + // create a new ticker for retrying the request ticker := time.NewTicker(5 * time.Second) defer ticker.Stop() for { + log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", u.Path, "attempt", attempt) + attempt++ select { case <-h.closeCh: log.Debug("Shutdown detected, terminating request") @@ -113,7 +124,6 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo if err == nil && res != nil { return res, nil } - log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", u.Path) } } }