Browse Source

fix: address review feedback

pull/1076/head
Steven Allen 4 years ago
parent
commit
2a72777ef9
  1. 1
      go.mod
  2. 1
      go.sum
  3. 15
      p2p/host/routed/routed.go
  4. 10
      p2p/net/mock/mock_test.go
  5. 5
      p2p/protocol/identify/id.go

1
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

1
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=

15
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()
}

10
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)

5
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
}

Loading…
Cancel
Save