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