Skip to content

Commit

Permalink
core/bloombits: drop nil-matcher special case
Browse files Browse the repository at this point in the history
  • Loading branch information
karalabe committed Sep 6, 2017
1 parent 451ffdb commit 564c8f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
12 changes: 2 additions & 10 deletions core/bloombits/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package bloombits

import (
"bytes"
"errors"
"math"
"sort"
Expand Down Expand Up @@ -171,15 +172,6 @@ func (m *Matcher) Start(begin, end uint64, results chan uint64) (*MatcherSession
}
// Iterate over all the blocks in the section and return the matching ones
for i := first; i <= last; i++ {
// If the bitset is nil, we're a special match-all cornercase
if res.bitset == nil {
select {
case <-session.quit:
return
case results <- i:
}
continue
}
// Skip the entire byte if no matches are found inside
next := res.bitset[(i-sectionStart)/8]
if next == 0 {
Expand Down Expand Up @@ -221,7 +213,7 @@ func (m *Matcher) run(begin, end uint64, buffer int, session *MatcherSession) ch
select {
case <-session.quit:
return
case source <- &partialMatches{i, nil}:
case source <- &partialMatches{i, bytes.Repeat([]byte{0xff}, int(m.sectionSize/8))}:
}
}
}()
Expand Down
5 changes: 5 additions & 0 deletions core/bloombits/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func TestMatcherRandom(t *testing.T) {
}
}

// Tests that matching on everything doesn't crash (special case internally).
func TestWildcardMatcher(t *testing.T) {
testMatcherBothModes(t, nil, 10000, 0)
}

// makeRandomIndexes generates a random filter system, composed on multiple filter
// criteria, each having one bloom list component for the address and arbitrarilly
// many topic bloom list components.
Expand Down

0 comments on commit 564c8f3

Please sign in to comment.