Merge pull request #1318 from filecoin-project/fix/net-cmds

fix a few libp2p related problems
This commit is contained in:
Whyrusleeping 2020-03-03 16:10:34 -08:00 committed by GitHub
commit e7f6554c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 2 deletions

View File

@ -285,7 +285,7 @@ var clientQueryAskCmd = &cli.Command{
var pid peer.ID var pid peer.ID
if pidstr := cctx.String("peerid"); pidstr != "" { if pidstr := cctx.String("peerid"); pidstr != "" {
p, err := peer.IDFromString(pidstr) p, err := peer.Decode(pidstr)
if err != nil { if err != nil {
return err return err
} }

View File

@ -2,10 +2,11 @@ package cli
import ( import (
"fmt" "fmt"
"github.com/libp2p/go-libp2p-core/peer"
"sort" "sort"
"strings" "strings"
"github.com/libp2p/go-libp2p-core/peer"
"gopkg.in/urfave/cli.v2" "gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/lotus/lib/addrutil" "github.com/filecoin-project/lotus/lib/addrutil"

1
go.mod
View File

@ -70,6 +70,7 @@ require (
github.com/libp2p/go-libp2p-record v0.1.1 github.com/libp2p/go-libp2p-record v0.1.1
github.com/libp2p/go-libp2p-routing-helpers v0.1.0 github.com/libp2p/go-libp2p-routing-helpers v0.1.0
github.com/libp2p/go-libp2p-secio v0.2.1 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-tls v0.1.0
github.com/libp2p/go-libp2p-yamux v0.2.1 github.com/libp2p/go-libp2p-yamux v0.2.1
github.com/libp2p/go-maddr-filter v0.0.5 github.com/libp2p/go-maddr-filter v0.0.5

View File

@ -2,6 +2,7 @@ package impl
import ( import (
"context" "context"
"github.com/filecoin-project/lotus/node/modules/lp2p" "github.com/filecoin-project/lotus/node/modules/lp2p"
logging "github.com/ipfs/go-log/v2" 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/host"
"github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
swarm "github.com/libp2p/go-libp2p-swarm"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
"go.uber.org/fx" "go.uber.org/fx"
"golang.org/x/xerrors" "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 { 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) return a.Host.Connect(ctx, p)
} }