core/filtermaps, eth/filters: fixed linter issues
This commit is contained in:
parent
05f8d20185
commit
262b82d3ce
|
@ -218,7 +218,6 @@ func (f *FilterMaps) tryUpdateHead(newHead *types.Header) bool {
|
|||
f.lastLogHeadUpdate = time.Now()
|
||||
}
|
||||
}
|
||||
|
||||
}()
|
||||
|
||||
if !f.startHeadUpdate {
|
||||
|
@ -601,7 +600,7 @@ func (f *FilterMaps) applyUpdateBatch(u *updateBatch) {
|
|||
}
|
||||
}
|
||||
|
||||
// updatedRangeLength returns the lenght of the updated filter map range.
|
||||
// updatedRangeLength returns the length of the updated filter map range.
|
||||
func (u *updateBatch) updatedRangeLength() uint32 {
|
||||
return u.afterLastMap - u.firstMap
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package filtermaps
|
||||
|
||||
import (
|
||||
crand "crypto/rand"
|
||||
"crypto/sha256"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
|
@ -324,7 +325,7 @@ func (tc *testChain) addBlocks(count, maxTxPerBlock, maxLogsPerReceipt, maxTopic
|
|||
for i := range receipt.Logs {
|
||||
log := &types.Log{}
|
||||
receipt.Logs[i] = log
|
||||
rand.Read(log.Address[:])
|
||||
crand.Read(log.Address[:])
|
||||
var topicCount int
|
||||
if random {
|
||||
topicCount = rand.Intn(maxTopicsPerLog + 1)
|
||||
|
@ -333,7 +334,7 @@ func (tc *testChain) addBlocks(count, maxTxPerBlock, maxLogsPerReceipt, maxTopic
|
|||
}
|
||||
log.Topics = make([]common.Hash, topicCount)
|
||||
for j := range log.Topics {
|
||||
rand.Read(log.Topics[j][:])
|
||||
crand.Read(log.Topics[j][:])
|
||||
}
|
||||
}
|
||||
gen.AddUncheckedReceipt(receipt)
|
||||
|
|
|
@ -168,7 +168,6 @@ func GetPotentialMatches(ctx context.Context, backend MatcherBackend, firstBlock
|
|||
close(task.done)
|
||||
}
|
||||
wg.Done()
|
||||
return
|
||||
}
|
||||
|
||||
for i := 0; i < 4; i++ {
|
||||
|
|
|
@ -18,6 +18,7 @@ package filtermaps
|
|||
|
||||
import (
|
||||
"context"
|
||||
crand "crypto/rand"
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
|
@ -46,7 +47,7 @@ func TestMatcher(t *testing.T) {
|
|||
var ok bool
|
||||
addresses := make([]common.Address, rand.Intn(3))
|
||||
for i := range addresses {
|
||||
rand.Read(addresses[i][:])
|
||||
crand.Read(addresses[i][:])
|
||||
}
|
||||
if len(addresses) > 0 {
|
||||
addresses[rand.Intn(len(addresses))] = log.Address
|
||||
|
@ -56,7 +57,7 @@ func TestMatcher(t *testing.T) {
|
|||
for j := range topics {
|
||||
topics[j] = make([]common.Hash, rand.Intn(3))
|
||||
for i := range topics[j] {
|
||||
rand.Read(topics[j][i][:])
|
||||
crand.Read(topics[j][i][:])
|
||||
}
|
||||
if len(topics[j]) > 0 {
|
||||
topics[j][rand.Intn(len(topics[j]))] = log.Topics[j]
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package filtermaps
|
||||
|
||||
import (
|
||||
crand "crypto/rand"
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
|
@ -32,7 +33,7 @@ func TestSingleMatch(t *testing.T) {
|
|||
mapIndex := rand.Uint32()
|
||||
lvIndex := uint64(mapIndex)<<params.logValuesPerMap + uint64(rand.Intn(int(params.valuesPerMap)))
|
||||
var lvHash common.Hash
|
||||
rand.Read(lvHash[:])
|
||||
crand.Read(lvHash[:])
|
||||
row := FilterRow{params.columnIndex(lvIndex, lvHash)}
|
||||
matches := params.potentialMatches(row, mapIndex, lvHash)
|
||||
// check if it has been reverse transformed correctly
|
||||
|
@ -66,11 +67,11 @@ func TestPotentialMatches(t *testing.T) {
|
|||
for i := range lvIndices {
|
||||
// add testPmLen single entries with different log value hashes at different indices
|
||||
lvIndices[i] = lvStart + uint64(rand.Intn(int(params.valuesPerMap)))
|
||||
rand.Read(lvHashes[i][:])
|
||||
crand.Read(lvHashes[i][:])
|
||||
row = append(row, params.columnIndex(lvIndices[i], lvHashes[i]))
|
||||
}
|
||||
// add the same log value hash at the first testPmLen log value indices of the map's range
|
||||
rand.Read(lvHashes[testPmLen][:])
|
||||
crand.Read(lvHashes[testPmLen][:])
|
||||
for lvIndex := lvStart; lvIndex < lvStart+testPmLen; lvIndex++ {
|
||||
row = append(row, params.columnIndex(lvIndex, lvHashes[testPmLen]))
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ import (
|
|||
type testBackend struct {
|
||||
db ethdb.Database
|
||||
fm *filtermaps.FilterMaps
|
||||
sections uint64
|
||||
txFeed event.Feed
|
||||
logsFeed event.Feed
|
||||
rmLogsFeed event.Feed
|
||||
|
|
|
@ -460,7 +460,7 @@ func TestRangeLogs(t *testing.T) {
|
|||
go func(filter *Filter) {
|
||||
filter.Logs(context.Background())
|
||||
// ensure that filter will not be blocked if we exit early
|
||||
for _ = range filter.rangeLogsTestHook {
|
||||
for range filter.rangeLogsTestHook {
|
||||
}
|
||||
}(filter)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue