diff --git a/p2p/host/relay/autorelay.go b/p2p/host/relay/autorelay.go index a8092addad..64f6522a5f 100644 --- a/p2p/host/relay/autorelay.go +++ b/p2p/host/relay/autorelay.go @@ -247,15 +247,7 @@ func (ar *AutoRelay) discoverRelays(ctx context.Context) ([]peer.AddrInfo, error ctx, cancel := context.WithTimeout(ctx, 30*time.Second) defer cancel() - var ret []peer.AddrInfo - ch, err := ar.discover.FindPeers(ctx, RelayRendezvous, discovery.Limit(1000)) - if err != nil { - return nil, err - } - for p := range ch { - ret = append(ret, p) - } - return ret, nil + return discovery.FindPeers(ctx, ar.discover, RelayRendezvous, discovery.Limit(1000)) } func (ar *AutoRelay) selectRelays(ctx context.Context, pis []peer.AddrInfo) []peer.AddrInfo { diff --git a/p2p/host/routed/routed.go b/p2p/host/routed/routed.go index 9f6a54380e..ca5ce5e3f7 100644 --- a/p2p/host/routed/routed.go +++ b/p2p/host/routed/routed.go @@ -118,21 +118,17 @@ func (rh *RoutedHost) findPeerAddrs(ctx context.Context, id peer.ID) ([]ma.Multi if pi.ID != id { err = fmt.Errorf("routing failure: provided addrs for different peer") - logRoutingErrDifferentPeers(ctx, id, pi.ID, err) + log.Errorw("got wrong peer", + "error", err, + "wantedPeer", id, + "gotPeer", pi.ID, + ) return nil, err } return pi.Addrs, nil } -func logRoutingErrDifferentPeers(ctx context.Context, wanted, got peer.ID, err error) { - lm := make(lgbl.DeferredMap) - lm["error"] = err - lm["wantedPeer"] = func() interface{} { return wanted.Pretty() } - lm["gotPeer"] = func() interface{} { return got.Pretty() } - // log.Event(ctx, "routingError", lm) -} - func (rh *RoutedHost) ID() peer.ID { return rh.host.ID() } diff --git a/p2p/net/mock/mock_test.go b/p2p/net/mock/mock_test.go index b736cac218..3ed721ea42 100644 --- a/p2p/net/mock/mock_test.go +++ b/p2p/net/mock/mock_test.go @@ -19,16 +19,6 @@ import ( tnet "github.com/libp2p/go-libp2p-testing/net" ) -// Unused code: -// -// func randPeer(t *testing.T) peer.ID { -// p, err := test.RandPeerID() -// if err != nil { -// t.Fatal(err) -// } -// return p -// } - func TestNetworkSetup(t *testing.T) { ctx := context.Background() id1 := tnet.RandIdentityOrFatal(t) diff --git a/p2p/protocol/identify/id.go b/p2p/protocol/identify/id.go index 2fe2703fbb..d09d650173 100644 --- a/p2p/protocol/identify/id.go +++ b/p2p/protocol/identify/id.go @@ -373,7 +373,10 @@ func (ids *IDService) identifyConn(c network.Conn, signal chan struct{}) { // ok give the response to our handler. if err = msmux.SelectProtoOrFail(ID, s); err != nil { - // log.Event(context.TODO(), "IdentifyOpenFailed", c.RemotePeer(), logging.Metadata{"error": err}) + log.Infow("failed negotiate identify protocol with peer", + "peer", c.RemotePeer(), + "error", err, + ) s.Reset() return }