From 2a72777ef911a108dce8b3bb73d033356f95e05d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 29 Apr 2021 14:07:16 -0700 Subject: [PATCH] fix: address review feedback --- go.mod | 1 - go.sum | 1 - p2p/host/routed/routed.go | 15 +++++---------- p2p/net/mock/mock_test.go | 10 ---------- p2p/protocol/identify/id.go | 5 ++++- 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index f6bf33eaa..ebb21a176 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,6 @@ require ( github.com/libp2p/go-libp2p-circuit v0.4.0 github.com/libp2p/go-libp2p-core v0.8.5 github.com/libp2p/go-libp2p-discovery v0.5.0 - github.com/libp2p/go-libp2p-loggables v0.1.0 github.com/libp2p/go-libp2p-mplex v0.4.1 github.com/libp2p/go-libp2p-nat v0.0.6 github.com/libp2p/go-libp2p-netutil v0.1.0 diff --git a/go.sum b/go.sum index 4aa7591e1..73e2046d6 100644 --- a/go.sum +++ b/go.sum @@ -287,7 +287,6 @@ github.com/libp2p/go-libp2p-discovery v0.2.0/go.mod h1:s4VGaxYMbw4+4+tsoQTqh7wfx github.com/libp2p/go-libp2p-discovery v0.3.0/go.mod h1:o03drFnz9BVAZdzC/QUQ+NeQOu38Fu7LJGEOK2gQltw= github.com/libp2p/go-libp2p-discovery v0.5.0 h1:Qfl+e5+lfDgwdrXdu4YNCWyEo3fWuP+WgN9mN0iWviQ= github.com/libp2p/go-libp2p-discovery v0.5.0/go.mod h1:+srtPIU9gDaBNu//UHvcdliKBIcr4SfDcm0/PfPJLug= -github.com/libp2p/go-libp2p-loggables v0.1.0 h1:h3w8QFfCt2UJl/0/NW4K829HX/0S4KD31PQ7m8UXXO8= github.com/libp2p/go-libp2p-loggables v0.1.0/go.mod h1:EyumB2Y6PrYjr55Q3/tiJ/o3xoDasoRYM7nOzEpoa90= github.com/libp2p/go-libp2p-mplex v0.2.0/go.mod h1:Ejl9IyjvXJ0T9iqUTE1jpYATQ9NM3g+OtR+EMMODbKo= github.com/libp2p/go-libp2p-mplex v0.2.1/go.mod h1:SC99Rxs8Vuzrf/6WhmH41kNn13TiYdAWNYHrwImKLnE= diff --git a/p2p/host/routed/routed.go b/p2p/host/routed/routed.go index 9f6a54380..0c8c3e487 100644 --- a/p2p/host/routed/routed.go +++ b/p2p/host/routed/routed.go @@ -14,7 +14,6 @@ import ( "github.com/libp2p/go-libp2p-core/protocol" logging "github.com/ipfs/go-log" - lgbl "github.com/libp2p/go-libp2p-loggables" ma "github.com/multiformats/go-multiaddr" ) @@ -118,21 +117,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 b736cac21..3ed721ea4 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 2fe2703fb..d09d65017 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 }