Trivial code cleanup aiming to reduce Go compiler warnings (#451)

* simplify range traversal

* simplify channel read for single select case

* delete rand.Seed() deprecated in Go 1.20 and no-op as of Go 1.24

* simplify range traversal

* simplify channel read for single select case

* remove redundant type from array

* simplify range traversal

* simplify channel read for single select case
This commit is contained in:
Black Swan 2025-11-07 07:13:39 +02:00 committed by GitHub
parent 8d3a334058
commit 5e07ac92b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 27 deletions

View File

@ -43,7 +43,6 @@ func newBackoff(ctx context.Context, sizeThreshold int, cleanupInterval time.Dur
info: make(map[peer.ID]*backoffHistory),
}
rand.Seed(time.Now().UnixNano()) // used for jitter
go b.cleanupLoop(ctx)
return b

View File

@ -3469,12 +3469,10 @@ func TestBloomRouting(t *testing.T) {
}
go func() {
for _ = range sub {
select {
case err := <-errch:
if err != nil {
errs = append(errs, err)
}
for range sub {
err := <-errch
if err != nil {
errs = append(errs, err)
}
}
g.Done()
@ -3573,13 +3571,12 @@ func TestBloomPropagationOverSubTreeTopology(t *testing.T) {
var msg *struct{} = nil
go func() {
for i := 0; i < len(subs); i++ {
select {
case m := <-msgch:
msg = &m
cancel()
}
for range subs {
m := <-msgch
msg = &m
cancel()
}
}()
g.Wait()
if msg == nil {
@ -3796,12 +3793,10 @@ func assertReceivedBitmaskSubgroup(t *testing.T, ctx context.Context, subs [][]*
var msg *struct{} = nil
go func() {
for i := 0; i < len(subs); i++ {
select {
case m := <-msgch:
msg = &m
cancel()
}
for range subs {
m := <-msgch
msg = &m
cancel()
}
}()
g.Wait()

View File

@ -32,15 +32,15 @@ func TestBasicSubscriptionFilter(t *testing.T) {
bitmask3 := []byte{0x00, 0x00, 0x02, 0x00}
yes := true
subs := []*pb.RPC_SubOpts{
&pb.RPC_SubOpts{
{
Bitmask: bitmask1,
Subscribe: yes,
},
&pb.RPC_SubOpts{
{
Bitmask: bitmask2,
Subscribe: yes,
},
&pb.RPC_SubOpts{
{
Bitmask: bitmask3,
Subscribe: yes,
},
@ -88,24 +88,24 @@ func TestSubscriptionFilterDeduplication(t *testing.T) {
yes := true
no := false
subs := []*pb.RPC_SubOpts{
&pb.RPC_SubOpts{
{
Bitmask: bitmask1,
Subscribe: yes,
},
&pb.RPC_SubOpts{
{
Bitmask: bitmask1,
Subscribe: yes,
},
&pb.RPC_SubOpts{
{
Bitmask: bitmask2,
Subscribe: yes,
},
&pb.RPC_SubOpts{
{
Bitmask: bitmask2,
Subscribe: no,
},
&pb.RPC_SubOpts{
{
Bitmask: bitmask3,
Subscribe: yes,
},