mirror of
https://github.com/grassrootseconomics/cic-chain-events.git
synced 2024-11-22 15:56:45 +01:00
refactor: replace timer with ticker
This commit is contained in:
parent
4b2eb7b018
commit
0d5bc3a333
@ -48,20 +48,18 @@ func NewJanitor(o JanitorOpts) *Janitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *Janitor) Start(ctx context.Context) error {
|
func (j *Janitor) Start(ctx context.Context) error {
|
||||||
timer := time.NewTimer(j.sweepInterval)
|
ticker := time.NewTicker(j.sweepInterval)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
j.logg.Info("janitor: shutdown signal received")
|
j.logg.Info("janitor: shutdown signal received")
|
||||||
return nil
|
return nil
|
||||||
case <-timer.C:
|
case <-ticker.C:
|
||||||
j.logg.Debug("janitor: starting sweep")
|
j.logg.Debug("janitor: starting sweep")
|
||||||
if err := j.QueueMissingBlocks(context.Background()); err != nil {
|
if err := j.QueueMissingBlocks(context.Background()); err != nil {
|
||||||
j.logg.Error("janitor: queue missing blocks error", "error", err)
|
j.logg.Error("janitor: queue missing blocks error", "error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
timer.Reset(j.sweepInterval)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user