Skip to content

Commit

Permalink
Add default cases to filter event emitters
Browse files Browse the repository at this point in the history
  • Loading branch information
wizeguyy committed Oct 23, 2024
1 parent 2dd3f20 commit 4931eaa
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions quai/filters/filter_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ func (es *EventSystem) handleLogs(filters filterIndex, ev []*types.Log) {
}
matchedLogs := filterLogs(ev, f.logsCrit.FromBlock, f.logsCrit.ToBlock, addresses, f.logsCrit.Topics)
if len(matchedLogs) > 0 {
f.logs <- matchedLogs
select {
case f.logs <- matchedLogs:
default:
}
}
}
}
Expand All @@ -371,7 +374,10 @@ func (es *EventSystem) handlePendingLogs(filters filterIndex, ev []*types.Log) {
}
matchedLogs := filterLogs(ev, nil, f.logsCrit.ToBlock, addresses, f.logsCrit.Topics)
if len(matchedLogs) > 0 {
f.logs <- matchedLogs
select {
case f.logs <- matchedLogs:
default:
}
}
}
}
Expand All @@ -387,7 +393,10 @@ func (es *EventSystem) handleRemovedLogs(filters filterIndex, ev core.RemovedLog
}
matchedLogs := filterLogs(ev.Logs, f.logsCrit.FromBlock, f.logsCrit.ToBlock, addresses, f.logsCrit.Topics)
if len(matchedLogs) > 0 {
f.logs <- matchedLogs
select {
case f.logs <- matchedLogs:
default:
}
}
}
}
Expand All @@ -398,19 +407,28 @@ func (es *EventSystem) handleTxsEvent(filters filterIndex, ev core.NewTxsEvent)
hashes = append(hashes, tx.Hash())
}
for _, f := range filters[PendingTransactionsSubscription] {
f.hashes <- hashes
select {
case f.hashes <- hashes:
default:
}
}
}

func (es *EventSystem) handleChainEvent(filters filterIndex, ev core.ChainEvent) {
for _, f := range filters[BlocksSubscription] {
f.headers <- ev.Block
select {
case f.headers <- ev.Block:
default:
}
}
}

func (es *EventSystem) handleUnlocksEvent(filters filterIndex, ev core.UnlocksEvent) {
for _, f := range filters[UnlocksSubscription] {
f.unlocks <- ev
select {
case f.unlocks <- ev:
default:
}
}
}

Expand Down

0 comments on commit 4931eaa

Please sign in to comment.