Skip to content

Commit

Permalink
Merge pull request #2273 from CortexFoundation/dev
Browse files Browse the repository at this point in the history
filter tiny fix
  • Loading branch information
ucwong authored Feb 24, 2025
2 parents eaf9a1d + 1429766 commit 5578413
Showing 1 changed file with 7 additions and 14 deletions.
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

0 comments on commit 5578413

Please sign in to comment.