From 0d5bc3a333014ca94da4b184ee743d00a964b667 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Fri, 24 Feb 2023 08:06:07 +0000 Subject: [PATCH] refactor: replace timer with ticker --- internal/syncer/janitor.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/syncer/janitor.go b/internal/syncer/janitor.go index be7bf97..1a3cd63 100644 --- a/internal/syncer/janitor.go +++ b/internal/syncer/janitor.go @@ -48,20 +48,18 @@ func NewJanitor(o JanitorOpts) *Janitor { } func (j *Janitor) Start(ctx context.Context) error { - timer := time.NewTimer(j.sweepInterval) + ticker := time.NewTicker(j.sweepInterval) for { select { case <-ctx.Done(): j.logg.Info("janitor: shutdown signal received") return nil - case <-timer.C: + case <-ticker.C: j.logg.Debug("janitor: starting sweep") if err := j.QueueMissingBlocks(context.Background()); err != nil { j.logg.Error("janitor: queue missing blocks error", "error", err) } - - timer.Reset(j.sweepInterval) } } }