Skip to content

Commit

Permalink
do not retry streaming is streaming is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
marino39 committed Apr 15, 2024
1 parent 21173ac commit 081b055
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions ethmonitor/ethmonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,17 +377,25 @@ func (m *Monitor) listenNewHead() <-chan uint64 {

retryStreamingTimer := time.NewTimer(m.options.StreamingRetryAfter)
for {
// if streaming is enabled, we'll retry streaming
if m.provider.IsStreamingEnabled() {
select {
case <-retryStreamingTimer.C:
// retry streaming
m.log.Info("ethmonitor: retrying streaming...")
goto reconnect
default:
// non-blocking
}
}

// Polling mode, where we poll for the latest block number
select {
case <-m.ctx.Done():
// if we're done, we'll close the nextBlock channel
close(nextBlock)
return

case <-retryStreamingTimer.C:
// retry streaming
m.log.Info("ethmonitor: retrying streaming...")
goto reconnect

case <-time.After(time.Duration(m.pollInterval.Load())):
nextBlock <- 0
}
Expand Down

0 comments on commit 081b055

Please sign in to comment.