Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various staticcheck fixes #710

Merged
merged 1 commit into from
Apr 8, 2021
Merged
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
1 change: 1 addition & 0 deletions dht_filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func isEUI(ip net.IP) bool {
}

func sameV6Net(a, b net.IP) bool {
//lint:ignore SA1021 We're comparing only parts of the IP address here.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is annoying, especially since we need both comments here (this new one for staticcheck, the //nolint for gopls (?)).
Furthermore, I think this is a false positive anyway: dominikh/go-tools#957.

return len(a) == net.IPv6len && len(b) == net.IPv6len && bytes.Equal(a[0:8], b[0:8]) //nolint
}

Expand Down
7 changes: 3 additions & 4 deletions dht_filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ import (
ic "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/multiformats/go-multiaddr"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr/net"
)

func TestIsRelay(t *testing.T) {
a, _ := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/5002/p2p/QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ/p2p-circuit/p2p/QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt")
a, _ := ma.NewMultiaddr("/ip4/127.0.0.1/tcp/5002/p2p/QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ/p2p-circuit/p2p/QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt")
if !isRelayAddr(a) {
t.Fatalf("thought %s was not a relay", a)
}
a, _ = multiaddr.NewMultiaddr("/p2p-circuit/p2p/QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt")
a, _ = ma.NewMultiaddr("/p2p-circuit/p2p/QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt")
if !isRelayAddr(a) {
t.Fatalf("thought %s was not a relay", a)
}
a, _ = multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/5002/p2p/QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ")
a, _ = ma.NewMultiaddr("/ip4/127.0.0.1/tcp/5002/p2p/QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ")
if isRelayAddr(a) {
t.Fatalf("thought %s was a relay", a)
}
Expand Down
4 changes: 2 additions & 2 deletions routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ func (dht *IpfsDHT) getValues(ctx context.Context, key string, stopQuery chan st
ID: p,
})
return nil, err
default:
return nil, err
case nil, internal.ErrInvalidRecord:
// in either of these cases, we want to keep going
default:
return nil, err
}

// TODO: What should happen if the record is invalid?
Expand Down