Commit a035114e authored by Marten Seemann's avatar Marten Seemann

fix staticcheck

parent b90e3fed
......@@ -120,15 +120,6 @@ func (b *bucket) remove(id peer.ID) bool {
return false
}
func (b *bucket) moveToFront(id peer.ID) {
for e := b.list.Front(); e != nil; e = e.Next() {
if e.Value.(*PeerInfo).Id == id {
b.list.MoveToFront(e)
}
}
}
func (b *bucket) pushFront(p *PeerInfo) {
b.list.PushFront(p)
}
......
......@@ -92,11 +92,11 @@ func TestDistancesAndCenterSorting(t *testing.T) {
return big.NewInt(a).Cmp(b)
}
if 0 != cmp(0, keys[2].Distance(keys[3])) {
if cmp(0, keys[2].Distance(keys[3])) != 0 {
t.Errorf("distance calculation wrong: %v", keys[2].Distance(keys[3]))
}
if 0 != cmp(1, keys[2].Distance(keys[4])) {
if cmp(1, keys[2].Distance(keys[4])) != 0 {
t.Errorf("distance calculation wrong: %v", keys[2].Distance(keys[4]))
}
......
......@@ -20,8 +20,6 @@ type mockPeerGroupFilter struct {
peerAddressFunc func(p peer.ID) []ma.Multiaddr
allowFnc func(g PeerGroupInfo) bool
incrementFunc func(g PeerGroupInfo)
dectementFunc func(g PeerGroupInfo)
}
func (m *mockPeerGroupFilter) Allow(g PeerGroupInfo) (allow bool) {
......
......@@ -264,9 +264,7 @@ func (rt *RoutingTable) GetPeerInfos() []PeerInfo {
var pis []PeerInfo
for _, b := range rt.buckets {
for _, p := range b.peers() {
pis = append(pis, p)
}
pis = append(pis, b.peers()...)
}
return pis
}
......
......@@ -155,8 +155,10 @@ func TestEmptyBucketCollapse(t *testing.T) {
// add peer with cpl 0 and cpl 1 and verify we have two buckets.
b, err = rt.TryAddPeer(p1, true, false)
require.NoError(t, err)
require.True(t, b)
b, err = rt.TryAddPeer(p2, true, false)
require.NoError(t, err)
require.True(t, b)
rt.tabLock.Lock()
require.Len(t, rt.buckets, 2)
......
package kbucket
import (
"bytes"
"errors"
"github.com/libp2p/go-libp2p-core/peer"
......@@ -21,10 +20,6 @@ var ErrLookupFailure = errors.New("failed to find any peer in table")
// peer.ID or a util.Key. This unifies the keyspace
type ID []byte
func (id ID) equal(other ID) bool {
return bytes.Equal(id, other)
}
func (id ID) less(other ID) bool {
a := ks.Key{Space: ks.XORKeySpace, Bytes: id}
b := ks.Key{Space: ks.XORKeySpace, Bytes: other}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment