|
|
@ -20,6 +20,7 @@ import ( |
|
|
|
"context" |
|
|
|
"context" |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
|
|
|
|
"slices" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/core/bloombits" |
|
|
|
"github.com/ethereum/go-ethereum/core/bloombits" |
|
|
@ -347,16 +348,6 @@ func (f *Filter) pendingLogs() []*types.Log { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// includes returns true if the element is present in the list.
|
|
|
|
|
|
|
|
func includes[T comparable](things []T, element T) bool { |
|
|
|
|
|
|
|
for _, thing := range things { |
|
|
|
|
|
|
|
if thing == element { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// filterLogs creates a slice of logs matching the given criteria.
|
|
|
|
// filterLogs creates a slice of logs matching the given criteria.
|
|
|
|
func filterLogs(logs []*types.Log, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) []*types.Log { |
|
|
|
func filterLogs(logs []*types.Log, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) []*types.Log { |
|
|
|
var check = func(log *types.Log) bool { |
|
|
|
var check = func(log *types.Log) bool { |
|
|
@ -366,7 +357,7 @@ func filterLogs(logs []*types.Log, fromBlock, toBlock *big.Int, addresses []comm |
|
|
|
if toBlock != nil && toBlock.Int64() >= 0 && toBlock.Uint64() < log.BlockNumber { |
|
|
|
if toBlock != nil && toBlock.Int64() >= 0 && toBlock.Uint64() < log.BlockNumber { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
if len(addresses) > 0 && !includes(addresses, log.Address) { |
|
|
|
if len(addresses) > 0 && !slices.Contains(addresses, log.Address) { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
// If the to filtered topics is greater than the amount of topics in logs, skip.
|
|
|
|
// If the to filtered topics is greater than the amount of topics in logs, skip.
|
|
|
@ -377,7 +368,7 @@ func filterLogs(logs []*types.Log, fromBlock, toBlock *big.Int, addresses []comm |
|
|
|
if len(sub) == 0 { |
|
|
|
if len(sub) == 0 { |
|
|
|
continue // empty rule set == wildcard
|
|
|
|
continue // empty rule set == wildcard
|
|
|
|
} |
|
|
|
} |
|
|
|
if !includes(sub, log.Topics[i]) { |
|
|
|
if !slices.Contains(sub, log.Topics[i]) { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|