Skip to content

Commit

Permalink
Retry sync in case of error
Browse files Browse the repository at this point in the history
  • Loading branch information
martinboehm committed May 27, 2019
1 parent b6e5055 commit 77bea0e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion blockbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,12 @@ func syncIndexLoop() {
// resync index about every 15 minutes if there are no chanSyncIndex requests, with debounce 1 second
tickAndDebounce(time.Duration(*resyncIndexPeriodMs)*time.Millisecond, debounceResyncIndexMs*time.Millisecond, chanSyncIndex, func() {
if err := syncWorker.ResyncIndex(onNewBlockHash, false); err != nil {
glog.Error("syncIndexLoop ", errors.ErrorStack(err))
glog.Error("syncIndexLoop ", errors.ErrorStack(err), ", will retry...")
// retry once in case of random network error, after a slight delay
time.Sleep(time.Millisecond * 2500)
if err := syncWorker.ResyncIndex(onNewBlockHash, false); err != nil {
glog.Error("syncIndexLoop ", errors.ErrorStack(err))
}
}
})
glog.Info("syncIndexLoop stopped")
Expand Down

0 comments on commit 77bea0e

Please sign in to comment.