292: Backfill gaps in the recent past on startup when tracking head. #395

Merged
telackey merged 11 commits from telackey/292 into v1.11.6-statediff-v5 2023-06-24 04:04:57 +00:00
Showing only changes of commit 48a758840d - Show all commits

View File

@ -1185,12 +1185,7 @@ func (sds *Service) Backfill() {
// A gap can be created in this way if there is some problem in statediffing (eg, DB connectivity is lost,
// while the chain keeps syncing), if the process is terminated with a statediff in-flight, etc.
func (sds *Service) backfillHeadGap(indexerBlockNumber uint64, chainBlockNumber uint64) {
headGap := chainBlockNumber - indexerBlockNumber
var ch = make(chan uint64, headGap)
for bn := indexerBlockNumber; bn <= chainBlockNumber; bn++ {
ch <- bn
}
var ch = make(chan uint64)
var wg sync.WaitGroup
for i := uint(0); i < sds.numWorkers; i++ {
wg.Add(1)
@ -1215,6 +1210,10 @@ func (sds *Service) backfillHeadGap(indexerBlockNumber uint64, chainBlockNumber
}
}(i)
}
for bn := indexerBlockNumber; bn <= chainBlockNumber; bn++ {
ch <- bn
}
close(ch)
wg.Wait()
}