Skip to content

Commit

Permalink
ethmonitor: timer stop
Browse files Browse the repository at this point in the history
  • Loading branch information
pkieltyka committed Apr 16, 2024
1 parent b69b303 commit c6a8a08
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ethmonitor/ethmonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ func (m *Monitor) listenNewHead() <-chan uint64 {
var streamingErrorCount int
var streamingErrorLastTime time.Time

blockTimer := time.NewTimer(3 * m.options.ExpectedBlockInterval)
defer blockTimer.Stop()

retryStreamingTimer := time.NewTimer(m.options.StreamingRetryAfter)
defer retryStreamingTimer.Stop()

reconnect:
// reset the latest head block
latestHeadBlock.Store(0)
Expand Down Expand Up @@ -334,7 +340,6 @@ func (m *Monitor) listenNewHead() <-chan uint64 {
goto reconnect
}

blockTimer := time.NewTimer(3 * m.options.ExpectedBlockInterval)
for {
select {
case <-m.ctx.Done():
Expand Down Expand Up @@ -375,7 +380,6 @@ func (m *Monitor) listenNewHead() <-chan uint64 {
// We default to polling if streaming is not enabled
m.log.Info("ethmonitor: starting poll head listener")

retryStreamingTimer := time.NewTimer(m.options.StreamingRetryAfter)
for {
// if streaming is enabled, we'll retry streaming
if m.provider.IsStreamingEnabled() {
Expand Down

0 comments on commit c6a8a08

Please sign in to comment.