diff --git a/cli/client.go b/cli/client.go index 28b02e268..f735515b2 100644 --- a/cli/client.go +++ b/cli/client.go @@ -285,7 +285,7 @@ var clientQueryAskCmd = &cli.Command{ var pid peer.ID if pidstr := cctx.String("peerid"); pidstr != "" { - p, err := peer.IDFromString(pidstr) + p, err := peer.Decode(pidstr) if err != nil { return err } diff --git a/cli/net.go b/cli/net.go index ac559e919..e7a45c0e2 100644 --- a/cli/net.go +++ b/cli/net.go @@ -2,10 +2,11 @@ package cli import ( "fmt" - "github.com/libp2p/go-libp2p-core/peer" "sort" "strings" + "github.com/libp2p/go-libp2p-core/peer" + "gopkg.in/urfave/cli.v2" "github.com/filecoin-project/lotus/lib/addrutil" diff --git a/go.mod b/go.mod index 00076cee5..09ba80047 100644 --- a/go.mod +++ b/go.mod @@ -70,6 +70,7 @@ require ( github.com/libp2p/go-libp2p-record v0.1.1 github.com/libp2p/go-libp2p-routing-helpers v0.1.0 github.com/libp2p/go-libp2p-secio v0.2.1 + github.com/libp2p/go-libp2p-swarm v0.2.2 github.com/libp2p/go-libp2p-tls v0.1.0 github.com/libp2p/go-libp2p-yamux v0.2.1 github.com/libp2p/go-maddr-filter v0.0.5 diff --git a/node/impl/common.go b/node/impl/common.go index 1420a7b7e..359a64543 100644 --- a/node/impl/common.go +++ b/node/impl/common.go @@ -2,6 +2,7 @@ package impl import ( "context" + "github.com/filecoin-project/lotus/node/modules/lp2p" logging "github.com/ipfs/go-log/v2" @@ -10,6 +11,7 @@ import ( "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" + swarm "github.com/libp2p/go-libp2p-swarm" ma "github.com/multiformats/go-multiaddr" "go.uber.org/fx" "golang.org/x/xerrors" @@ -69,6 +71,10 @@ func (a *CommonAPI) NetPeers(context.Context) ([]peer.AddrInfo, error) { } func (a *CommonAPI) NetConnect(ctx context.Context, p peer.AddrInfo) error { + if swrm, ok := a.Host.Network().(*swarm.Swarm); ok { + swrm.Backoff().Clear(p.ID) + } + return a.Host.Connect(ctx, p) }