Merge pull request #392 from maticnetwork/v0.2.16-candidate

v0.2.16 state sync fix
This commit is contained in:
Victor Castell 2022-05-10 17:29:45 +02:00 committed by GitHub
commit f083705e00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -99,11 +99,22 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo
u.Path = rawPath u.Path = rawPath
u.RawQuery = rawQuery 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 // create a new ticker for retrying the request
ticker := time.NewTicker(5 * time.Second) ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop() defer ticker.Stop()
for { for {
log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", u.Path, "attempt", attempt)
attempt++
select { select {
case <-h.closeCh: case <-h.closeCh:
log.Debug("Shutdown detected, terminating request") log.Debug("Shutdown detected, terminating request")
@ -113,7 +124,6 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo
if err == nil && res != nil { if err == nil && res != nil {
return res, nil return res, nil
} }
log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", u.Path)
} }
} }
} }