Skip to content

Commit

Permalink
fix: pendingLogs nil pointer error (#53)
Browse files Browse the repository at this point in the history
### Description

fix `pendingLogs` nil pointer crash
  • Loading branch information
0xcb9ff9 authored Nov 1, 2023
1 parent 87bfbf3 commit d4e6601
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion eth/filters/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (f *Filter) Logs(ctx context.Context) ([]*types.Log, error) {
var (
head = header.Number.Uint64()
end = uint64(f.end)
pending = f.end == rpc.LatestBlockNumber.Int64()
pending = f.end == rpc.PendingBlockNumber.Int64()
)
if f.begin == rpc.LatestBlockNumber.Int64() {
f.begin = int64(head)
Expand Down Expand Up @@ -306,6 +306,10 @@ func (f *Filter) checkMatches(ctx context.Context, header *types.Header) (logs [
// pendingLogs returns the logs matching the filter criteria within the pending block.
func (f *Filter) pendingLogs() ([]*types.Log, error) {
block, receipts := f.backend.PendingBlockAndReceipts()
// the pending block might be nil if the miner is disabled
if block == nil || len(receipts) == 0 {
return nil, nil
}
if bloomFilter(block.Bloom(), f.addresses, f.topics) {
var unfiltered []*types.Log
for _, r := range receipts {
Expand Down

0 comments on commit d4e6601

Please sign in to comment.