From 262b82d3cef51520427b4f36727d6d43abd3765c Mon Sep 17 00:00:00 2001 From: Zsolt Felfoldi Date: Sun, 6 Oct 2024 23:10:04 +0200 Subject: [PATCH] core/filtermaps, eth/filters: fixed linter issues --- core/filtermaps/indexer.go | 3 +-- core/filtermaps/indexer_test.go | 5 +++-- core/filtermaps/matcher.go | 1 - core/filtermaps/matcher_test.go | 5 +++-- core/filtermaps/math_test.go | 7 ++++--- eth/filters/filter_system_test.go | 1 - eth/filters/filter_test.go | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/filtermaps/indexer.go b/core/filtermaps/indexer.go index 9bf705cf83..08563f0448 100644 --- a/core/filtermaps/indexer.go +++ b/core/filtermaps/indexer.go @@ -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 } diff --git a/core/filtermaps/indexer_test.go b/core/filtermaps/indexer_test.go index a20b062e40..84e348cd42 100644 --- a/core/filtermaps/indexer_test.go +++ b/core/filtermaps/indexer_test.go @@ -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) diff --git a/core/filtermaps/matcher.go b/core/filtermaps/matcher.go index 316a6dff37..593fab2743 100644 --- a/core/filtermaps/matcher.go +++ b/core/filtermaps/matcher.go @@ -168,7 +168,6 @@ func GetPotentialMatches(ctx context.Context, backend MatcherBackend, firstBlock close(task.done) } wg.Done() - return } for i := 0; i < 4; i++ { diff --git a/core/filtermaps/matcher_test.go b/core/filtermaps/matcher_test.go index 7754057d4b..0f05aec1d4 100644 --- a/core/filtermaps/matcher_test.go +++ b/core/filtermaps/matcher_test.go @@ -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] diff --git a/core/filtermaps/math_test.go b/core/filtermaps/math_test.go index 3210c833ac..5ab2c5aa8a 100644 --- a/core/filtermaps/math_test.go +++ b/core/filtermaps/math_test.go @@ -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)<