Skip to content

Commit

Permalink
ethmonitor: skip publish enqueuing if there are no subscribers
Browse files Browse the repository at this point in the history
  • Loading branch information
pkieltyka committed Aug 20, 2023
1 parent d236d09 commit 95a1f6f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ethmonitor/ethmonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,14 @@ func (m *Monitor) fetchBlockByHash(ctx context.Context, hash common.Hash) (*type
}

func (m *Monitor) publish(ctx context.Context, events Blocks) error {
// skip publish enqueuing if there are no subscribers
m.mu.Lock()
if len(m.subscribers) == 0 {
m.mu.Unlock()
return nil
}
m.mu.Unlock()

// Check for trail-behind-head mode and set maxBlockNum if applicable
maxBlockNum := uint64(0)
if m.options.TrailNumBlocksBehindHead > 0 {
Expand Down

0 comments on commit 95a1f6f

Please sign in to comment.