Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions dot/network/authoritydiscovery/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package authoritydiscovery
import (
"context"
"errors"
"slices"
"sync"

"github.com/libp2p/go-libp2p/core/peer"
Expand Down Expand Up @@ -293,10 +294,8 @@ func appendUniqueAuthorityID(slice []AuthorityID, auth AuthorityID) []AuthorityI
}

func appendUniquePeerID(slice []peer.ID, peerID peer.ID) []peer.ID {
for _, existing := range slice {
if existing == peerID {
return slice
}
if slices.Contains(slice, peerID) {
return slice
}
return append(slice, peerID)
}
9 changes: 2 additions & 7 deletions dot/rpc/modules/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package modules

import (
"net/http"
"slices"
)

var (
Expand Down Expand Up @@ -55,11 +56,5 @@ func (rm *RPCModule) Methods(r *http.Request, req *EmptyRequest, res *MethodsRes

// IsUnsafe returns true if the `name` has the suffix
func IsUnsafe(name string) bool {
for _, unsafe := range UnsafeMethods {
if name == unsafe {
return true
}
}

return false
return slices.Contains(UnsafeMethods, name)
}
12 changes: 2 additions & 10 deletions dot/state/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package state

import (
"errors"
"slices"
"testing"
"time"

Expand Down Expand Up @@ -460,22 +461,13 @@ func TestFinalization_DeleteBlock(t *testing.T) {

after := bs.bt.GetAllBlocks()

isIn := func(arr []common.Hash, b common.Hash) bool {
for _, a := range arr {
if b == a {
return true
}
}
return false
}

// assert that every block except finalised has been deleted
for _, b := range before {
if b == fin {
continue
}

if isIn(after, b) {
if slices.Contains(after, b) {
continue
}

Expand Down