Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter tiny fix #2273

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions ctxc/filters/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@ func (f *Filter) unindexedLogs(ctx context.Context, end uint64, logChan chan *ty
if err != nil {
return err
}
if len(found) > 0 {
}

for _, log := range found {
select {
case logChan <- log:
Expand All @@ -284,7 +281,12 @@ func (f *Filter) blockLogs(ctx context.Context, header *types.Header) ([]*types.
// checkMatches checks if the receipts belonging to the given header contain any log events that
// match the filter criteria. This function is called when the bloom filter signals a potential match.
func (f *Filter) checkMatches(ctx context.Context, header *types.Header) ([]*types.Log, error) {
logsList, err := f.sys.cachedGetLogs(ctx, header.Hash(), header.Number.Uint64())
hash := header.Hash()
// Logs in cache are partially filled with context data
// such as tx index, block hash, etc.
// Notably tx hash is NOT filled in because it needs
// access to block body data.
logsList, err := f.sys.cachedGetLogs(ctx, hash, header.Number.Uint64())
if err != nil {
return nil, err
}
Expand All @@ -294,7 +296,7 @@ func (f *Filter) checkMatches(ctx context.Context, header *types.Header) ([]*typ
if len(logs) > 0 {
// We have matching logs, check if we need to resolve full logs via the light client
if logs[0].TxHash == (common.Hash{}) {
receipts, err := f.sys.backend.GetReceipts(ctx, header.Hash())
receipts, err := f.sys.backend.GetReceipts(ctx, hash)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -325,15 +327,6 @@ func (f *Filter) pendingLogs() []*types.Log {
return nil
}

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.
func filterLogs(logs []*types.Log, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) []*types.Log {
var check = func(log *types.Log) bool {
Expand Down