Skip to content

Commit

Permalink
Merge pull request #392 from maticnetwork/v0.2.16-candidate
Browse files Browse the repository at this point in the history
v0.2.16 state sync fix
  • Loading branch information
Victor Castell authored May 10, 2022
2 parents 2321e64 + be01489 commit f083705
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion consensus/bor/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}
}
}
Expand Down

0 comments on commit f083705

Please sign in to comment.