forked from cerc-io/plugeth
core/bloombits: drop nil-matcher special case
This commit is contained in:
parent
451ffdb62b
commit
564c8f3ae6
@ -17,6 +17,7 @@
|
|||||||
package bloombits
|
package bloombits
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"math"
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
@ -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
|
// Iterate over all the blocks in the section and return the matching ones
|
||||||
for i := first; i <= last; i++ {
|
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
|
// Skip the entire byte if no matches are found inside
|
||||||
next := res.bitset[(i-sectionStart)/8]
|
next := res.bitset[(i-sectionStart)/8]
|
||||||
if next == 0 {
|
if next == 0 {
|
||||||
@ -221,7 +213,7 @@ func (m *Matcher) run(begin, end uint64, buffer int, session *MatcherSession) ch
|
|||||||
select {
|
select {
|
||||||
case <-session.quit:
|
case <-session.quit:
|
||||||
return
|
return
|
||||||
case source <- &partialMatches{i, nil}:
|
case source <- &partialMatches{i, bytes.Repeat([]byte{0xff}, int(m.sectionSize/8))}:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -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
|
// makeRandomIndexes generates a random filter system, composed on multiple filter
|
||||||
// criteria, each having one bloom list component for the address and arbitrarilly
|
// criteria, each having one bloom list component for the address and arbitrarilly
|
||||||
// many topic bloom list components.
|
// many topic bloom list components.
|
||||||
|
Loading…
Reference in New Issue
Block a user