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

Add state-sync logs for GetFilterLogs #58

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,20 @@ func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*ty
return nil, fmt.Errorf("filter not found")
}

borConfig := api.chainConfig.Bor

var filter *Filter

var borLogsFilter *BorBlockLogsFilter

if f.crit.BlockHash != nil {
// Block filter requested, construct a single-shot filter
filter = NewBlockFilter(api.backend, *f.crit.BlockHash, f.crit.Addresses, f.crit.Topics)

// Block bor filter
if api.borLogs {
borLogsFilter = NewBorBlockLogsFilter(api.backend, borConfig.Sprint, *f.crit.BlockHash, f.crit.Addresses, f.crit.Topics)
}
} else {
// Convert the RPC block numbers into internal representations
begin := rpc.LatestBlockNumber.Int64()
Expand All @@ -436,12 +446,27 @@ func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*ty
}
// Construct the range filter
filter = NewRangeFilter(api.backend, begin, end, f.crit.Addresses, f.crit.Topics)

if api.borLogs {
borLogsFilter = NewBorBlockLogsRangeFilter(api.backend, borConfig.Sprint, begin, end, f.crit.Addresses, f.crit.Topics)
}
}
// Run the filter and return all the logs
logs, err := filter.Logs(ctx)
if err != nil {
return nil, err
}

if borLogsFilter != nil {
// Run the filter and return all the logs
borBlockLogs, err := borLogsFilter.Logs(ctx)
if err != nil {
return nil, err
}

return returnLogs(types.MergeBorLogs(logs, borBlockLogs)), nil
}

return returnLogs(logs), nil
}

Expand Down