Skip to content

Commit 27600a5

Browse files
holimanfjl
authored andcommitted
eth/filters: change filter block to be by-ref (#26054)
This PR changes the block field in the filter to be a pointer, to disambiguate between empty hash and no hash
1 parent 99bbb33 commit 27600a5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

eth/filters/filter.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ type Filter struct {
3434
addresses []common.Address
3535
topics [][]common.Hash
3636

37-
block common.Hash // Block hash if filtering a single block
38-
begin, end int64 // Range interval if filtering multiple blocks
37+
block *common.Hash // Block hash if filtering a single block
38+
begin, end int64 // Range interval if filtering multiple blocks
3939

4040
matcher *bloombits.Matcher
4141
}
@@ -78,7 +78,7 @@ func (sys *FilterSystem) NewRangeFilter(begin, end int64, addresses []common.Add
7878
func (sys *FilterSystem) NewBlockFilter(block common.Hash, addresses []common.Address, topics [][]common.Hash) *Filter {
7979
// Create a generic filter and convert it into a block filter
8080
filter := newFilter(sys, addresses, topics)
81-
filter.block = block
81+
filter.block = &block
8282
return filter
8383
}
8484

@@ -96,8 +96,8 @@ func newFilter(sys *FilterSystem, addresses []common.Address, topics [][]common.
9696
// first block that contains matches, updating the start of the filter accordingly.
9797
func (f *Filter) Logs(ctx context.Context) ([]*types.Log, error) {
9898
// If we're doing singleton block filtering, execute and return
99-
if f.block != (common.Hash{}) {
100-
header, err := f.sys.backend.HeaderByHash(ctx, f.block)
99+
if f.block != nil {
100+
header, err := f.sys.backend.HeaderByHash(ctx, *f.block)
101101
if err != nil {
102102
return nil, err
103103
}

0 commit comments

Comments
 (0)