Skip to content

Commit

Permalink
chore: fix staticcheck errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed May 8, 2021
1 parent 141f163 commit 9243a83
Show file tree
Hide file tree
Showing 18 changed files with 82 additions and 1,567 deletions.
6 changes: 2 additions & 4 deletions examples/chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,8 @@ func main() {

}

// Wait until canceled
select {
case <-ctx.Done():
}
// Wait forever
select {}
}

func makeHost(ctx context.Context, port int, randomness io.Reader) (host.Host, error) {
Expand Down
4 changes: 1 addition & 3 deletions examples/chat/chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ func TestMain(t *testing.T) {
rw.Flush()
}()

select {
case <-ctx.Done():
}
<-ctx.Done()
})
}
6 changes: 2 additions & 4 deletions examples/echo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ func runListener(ctx context.Context, ha host.Host, listenPort int, insecure boo
}

// Wait until canceled
select {
case <-ctx.Done():
}
<-ctx.Done()
}

func runSender(ctx context.Context, ha host.Host, targetPeer string) {
Expand Down Expand Up @@ -155,7 +153,7 @@ func runSender(ctx context.Context, ha host.Host, targetPeer string) {
return
}

peerid, err := peer.IDB58Decode(pid)
peerid, err := peer.Decode(pid)
if err != nil {
log.Println(err)
return
Expand Down
2 changes: 0 additions & 2 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ require (
github.com/libp2p/go-libp2p-discovery v0.5.0
github.com/libp2p/go-libp2p-kad-dht v0.11.1
github.com/libp2p/go-libp2p-quic-transport v0.10.0
github.com/libp2p/go-libp2p-routing v0.1.0
github.com/libp2p/go-libp2p-secio v0.2.2
github.com/libp2p/go-libp2p-swarm v0.5.0
github.com/libp2p/go-libp2p-tls v0.1.3
github.com/multiformats/go-multiaddr v0.3.1
github.com/multiformats/go-multiaddr-net v0.2.0
)

// Ensure that examples always use the go-libp2p version in the same git checkout.
Expand Down
2 changes: 0 additions & 2 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ github.com/libp2p/go-libp2p-quic-transport v0.10.0/go.mod h1:RfJbZ8IqXIhxBRm5hqU
github.com/libp2p/go-libp2p-record v0.1.2/go.mod h1:pal0eNcT5nqZaTV7UGhqeGqxFgGdsU/9W//C8dqjQDk=
github.com/libp2p/go-libp2p-record v0.1.3 h1:R27hoScIhQf/A8XJZ8lYpnqh9LatJ5YbHs28kCIfql0=
github.com/libp2p/go-libp2p-record v0.1.3/go.mod h1:yNUff/adKIfPnYQXgp6FQmNu3gLJ6EMg7+/vv2+9pY4=
github.com/libp2p/go-libp2p-routing v0.1.0 h1:hFnj3WR3E2tOcKaGpyzfP4gvFZ3t8JkQmbapN0Ct+oU=
github.com/libp2p/go-libp2p-routing v0.1.0/go.mod h1:zfLhI1RI8RLEzmEaaPwzonRvXeeSHddONWkcTcB54nE=
github.com/libp2p/go-libp2p-routing-helpers v0.2.3/go.mod h1:795bh+9YeoFl99rMASoiVgHdi5bjack0N1+AFAdbvBw=
github.com/libp2p/go-libp2p-secio v0.2.2 h1:rLLPvShPQAcY6eNurKNZq3eZjPWfU9kXF2eI9jIYdrg=
github.com/libp2p/go-libp2p-secio v0.2.2/go.mod h1:wP3bS+m5AUnFA+OFO7Er03uO1mncHG0uVwGrwvjYlNY=
Expand Down
8 changes: 4 additions & 4 deletions examples/http-proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/libp2p/go-libp2p-core/peerstore"

ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"
)

// Protocol defines the libp2p protocol that we will use for the libp2p proxy
Expand Down Expand Up @@ -65,7 +65,7 @@ func NewProxyService(h host.Host, proxyAddr ma.Multiaddr, dest peer.ID) *ProxySe
fmt.Println("Proxy server is ready")
fmt.Println("libp2p-peer addresses:")
for _, a := range h.Addrs() {
fmt.Printf("%s/ipfs/%s\n", a, peer.IDB58Encode(h.ID()))
fmt.Printf("%s/ipfs/%s\n", a, peer.Encode(h.ID()))
}

return &ProxyService{
Expand Down Expand Up @@ -206,15 +206,15 @@ func addAddrToPeerstore(h host.Host, addr string) peer.ID {
log.Fatalln(err)
}

peerid, err := peer.IDB58Decode(pid)
peerid, err := peer.Decode(pid)
if err != nil {
log.Fatalln(err)
}

// Decapsulate the /ipfs/<peerID> part from the target
// /ip4/<a.b.c.d>/ipfs/<peer> becomes /ip4/<a.b.c.d>
targetPeerAddr, _ := ma.NewMultiaddr(
fmt.Sprintf("/ipfs/%s", peer.IDB58Encode(peerid)))
fmt.Sprintf("/ipfs/%s", peer.Encode(peerid)))
targetAddr := ipfsaddr.Decapsulate(targetPeerAddr)

// We have a peer ID and a targetAddr so we add
Expand Down
3 changes: 3 additions & 0 deletions examples/ipfs-camp-2019/06-Pubsub/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ func main() {
routingDiscovery := disc.NewRoutingDiscovery(dht)
disc.Advertise(ctx, routingDiscovery, string(chatProtocol))
peers, err := disc.FindPeers(ctx, routingDiscovery, string(chatProtocol))
if err != nil {
panic(err)
}
for _, peer := range peers {
notifee.HandlePeerFound(peer)
}
Expand Down
Loading

0 comments on commit 9243a83

Please sign in to comment.