Skip to content

Commit 7afe9ed

Browse files
authored
Merge pull request #742 from rustrover/main
2 parents abfa591 + 8925aa5 commit 7afe9ed

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

filters/event_system.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package filters
33
import (
44
"fmt"
55
"math/big"
6+
"slices"
67
"sync"
78
"time"
89

@@ -194,16 +195,6 @@ func (es *EventSystem) SubscribeNewHeads(headers chan *types.Header) *Subscripti
194195
return es.subscribe(sub)
195196
}
196197

197-
func includes(addresses []common.Address, a common.Address) bool {
198-
for _, addr := range addresses {
199-
if addr == a {
200-
return true
201-
}
202-
}
203-
204-
return false
205-
}
206-
207198
// filterLogs creates a slice of logs matching the given criteria.
208199
func filterLogs(logs []*types.Log, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) []*types.Log {
209200
var ret []*types.Log
@@ -216,22 +207,15 @@ Logs:
216207
continue
217208
}
218209

219-
if len(addresses) > 0 && !includes(addresses, log.Address) {
210+
if len(addresses) > 0 && !slices.Contains(addresses, log.Address) {
220211
continue
221212
}
222213
// If the to filtered topics is greater than the amount of topics in logs, skip.
223214
if len(topics) > len(log.Topics) {
224215
continue Logs
225216
}
226217
for i, sub := range topics {
227-
match := len(sub) == 0 // empty rule set == wildcard
228-
for _, topic := range sub {
229-
if log.Topics[i] == topic {
230-
match = true
231-
break
232-
}
233-
}
234-
if !match {
218+
if len(sub) > 0 && !slices.Contains(sub, log.Topics[i]) {
235219
continue Logs
236220
}
237221
}

0 commit comments

Comments
 (0)