Skip to content

Commit

Permalink
timer: do not drain the timer channel
Browse files Browse the repository at this point in the history
It's not need with Go 1.23+, see https://pkg.go.dev/time#NewTimer

Signed-off-by: Roman Khimov <roman@nspcc.ru>
  • Loading branch information
roman-khimov committed Feb 25, 2025
1 parent d79007d commit ff9ce39
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions timer/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,10 @@ func (t *Timer) Reset(height uint32, view byte, d time.Duration) {
t.tt = time.NewTimer(t.d)
} else {
t.tt = nil
drain(t.ch)
t.ch <- t.s
}
}

func drain(ch <-chan time.Time) {
select {
case <-ch:
default:
}
}

// stop stops the Timer.
func (t *Timer) stop() {
if t.tt != nil {
Expand Down

0 comments on commit ff9ce39

Please sign in to comment.