Skip to content

Commit

Permalink
ensure that the ticker stops when function returns
Browse files Browse the repository at this point in the history
  • Loading branch information
gatsbyz committed Nov 2, 2023
1 parent c5aa932 commit b6e7007
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@ func renderMonitorUI(ctx context.Context, ec *ethclient.Client, ms *monitorStatu

currentBn := ms.HeadBlock
uiEvents := ui.PollEvents()
ticker := time.NewTicker(time.Second).C
ticker := time.NewTicker(time.Second)
defer ticker.Stop()

redraw(ms)

Expand Down Expand Up @@ -653,7 +654,7 @@ func renderMonitorUI(ctx context.Context, ec *ethclient.Client, ms *monitorStatu
if !forceRedraw {
redraw(ms)
}
case <-ticker:
case <-ticker.C:
if currentBn != ms.HeadBlock {
currentBn = ms.HeadBlock
redraw(ms)
Expand Down

0 comments on commit b6e7007

Please sign in to comment.