From 39a710e1d64595eb8b904d2b777e7f43cdcc5bcc Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Wed, 29 Jun 2022 15:53:15 +0100 Subject: [PATCH] Address lint issues as a result of libp2p deprecations and tidy go mod Address staticcheck issues caused by deprecated APIs and `go mod tidy`. --- go.mod | 4 ++-- node/config/load.go | 2 +- node/impl/net/net.go | 2 +- node/modules/lp2p/relay.go | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 7e48c2a1d..268b1eef8 100644 --- a/go.mod +++ b/go.mod @@ -113,7 +113,6 @@ require ( github.com/libp2p/go-libp2p v0.20.1 github.com/libp2p/go-libp2p-connmgr v0.3.1 github.com/libp2p/go-libp2p-core v0.16.1 - github.com/libp2p/go-libp2p-discovery v0.7.0 github.com/libp2p/go-libp2p-kad-dht v0.15.0 github.com/libp2p/go-libp2p-noise v0.4.0 github.com/libp2p/go-libp2p-peerstore v0.7.0 @@ -122,7 +121,6 @@ require ( github.com/libp2p/go-libp2p-record v0.1.3 github.com/libp2p/go-libp2p-resource-manager v0.3.0 github.com/libp2p/go-libp2p-routing-helpers v0.2.3 - github.com/libp2p/go-libp2p-swarm v0.11.0 github.com/libp2p/go-libp2p-tls v0.4.1 github.com/libp2p/go-libp2p-yamux v0.9.1 github.com/libp2p/go-maddr-filter v0.1.0 @@ -261,9 +259,11 @@ require ( github.com/libp2p/go-cidranger v1.1.0 // indirect github.com/libp2p/go-flow-metrics v0.0.3 // indirect github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect + github.com/libp2p/go-libp2p-discovery v0.7.0 // indirect github.com/libp2p/go-libp2p-gostream v0.3.1 // indirect github.com/libp2p/go-libp2p-kbucket v0.4.7 // indirect github.com/libp2p/go-libp2p-loggables v0.1.0 // indirect + github.com/libp2p/go-libp2p-swarm v0.11.0 // indirect github.com/libp2p/go-msgio v0.2.0 // indirect github.com/libp2p/go-nat v0.1.0 // indirect github.com/libp2p/go-netroute v0.2.0 // indirect diff --git a/node/config/load.go b/node/config/load.go index a76db7caf..6f5731ea1 100644 --- a/node/config/load.go +++ b/node/config/load.go @@ -33,7 +33,7 @@ func FromFile(path string, def interface{}) (interface{}, error) { // FromReader loads config from a reader instance. func FromReader(reader io.Reader, def interface{}) (interface{}, error) { cfg := def - _, err := toml.DecodeReader(reader, cfg) + _, err := toml.NewDecoder(reader).Decode(cfg) if err != nil { return nil, err } diff --git a/node/impl/net/net.go b/node/impl/net/net.go index 260ba0f36..6e4e61ccf 100644 --- a/node/impl/net/net.go +++ b/node/impl/net/net.go @@ -11,9 +11,9 @@ import ( "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/protocol" - swarm "github.com/libp2p/go-libp2p-swarm" basichost "github.com/libp2p/go-libp2p/p2p/host/basic" "github.com/libp2p/go-libp2p/p2p/net/conngater" + "github.com/libp2p/go-libp2p/p2p/net/swarm" "github.com/libp2p/go-libp2p/p2p/protocol/ping" ma "github.com/multiformats/go-multiaddr" "go.uber.org/fx" diff --git a/node/modules/lp2p/relay.go b/node/modules/lp2p/relay.go index 78d04e33f..ec0e39ad2 100644 --- a/node/modules/lp2p/relay.go +++ b/node/modules/lp2p/relay.go @@ -6,7 +6,7 @@ import ( "github.com/libp2p/go-libp2p" coredisc "github.com/libp2p/go-libp2p-core/discovery" "github.com/libp2p/go-libp2p-core/routing" - discovery "github.com/libp2p/go-libp2p-discovery" + routingdisc "github.com/libp2p/go-libp2p/p2p/discovery/routing" ) func NoRelay() func() (opts Libp2pOpts, err error) { @@ -24,5 +24,5 @@ func Discovery(router BaseIpfsRouting) (coredisc.Discovery, error) { return nil, fmt.Errorf("no suitable routing for discovery") } - return discovery.NewRoutingDiscovery(crouter), nil + return routingdisc.NewRoutingDiscovery(crouter), nil }