@@ -302,6 +302,10 @@ func (m *Monitor) Provider() ethrpc.Interface {
302302 return m .provider
303303}
304304
305+ func (m * Monitor ) IsStreamingEnabled () bool {
306+ return ! m .options .StreamingDisabled && m .provider .IsStreamingEnabled ()
307+ }
308+
305309func (m * Monitor ) listenNewHead () <- chan uint64 {
306310 ch := make (chan uint64 )
307311
@@ -339,7 +343,7 @@ func (m *Monitor) listenNewHead() <-chan uint64 {
339343 // the monitor directly too.
340344
341345 // listen for new heads either via streaming or polling
342- if ! m . options . StreamingDisabled && m . provider .IsStreamingEnabled () && streamingErrCount < m .options .StreamingErrNumToSwitchToPolling {
346+ if m .IsStreamingEnabled () && streamingErrCount < m .options .StreamingErrNumToSwitchToPolling {
343347 // Streaming mode if available, where we listen for new heads
344348 // and push the new block number to the nextBlock channel.
345349 m .log .Info ("ethmonitor: starting stream head listener" )
@@ -387,7 +391,7 @@ func (m *Monitor) listenNewHead() <-chan uint64 {
387391 retryStreamingTimer := time .NewTimer (m .options .StreamingRetryAfter )
388392 for {
389393 // if streaming is enabled, we'll retry streaming
390- if m .provider . IsStreamingEnabled () {
394+ if m .IsStreamingEnabled () {
391395 select {
392396 case <- retryStreamingTimer .C :
393397 // retry streaming
@@ -759,7 +763,7 @@ func (m *Monitor) fetchNextBlock(ctx context.Context) (*types.Block, []byte, boo
759763 nextBlockPayload , err := m .fetchRawBlockByNumber (ctx , m .nextBlockNumber )
760764 if errors .Is (err , ethereum .NotFound ) {
761765 miss = true
762- if m .provider . IsStreamingEnabled () {
766+ if m .IsStreamingEnabled () {
763767 // in streaming mode, we'll use a shorter time to pause before we refetch
764768 time .Sleep (200 * time .Millisecond )
765769 } else {
0 commit comments