diff --git a/dht.go b/dht.go index 426e0942a..da3c5cc33 100644 --- a/dht.go +++ b/dht.go @@ -8,6 +8,13 @@ import ( "sync" "time" + "github.com/libp2p/go-libp2p-core/host" + "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/peerstore" + "github.com/libp2p/go-libp2p-core/protocol" + "github.com/libp2p/go-libp2p-core/routing" + "go.opencensus.io/tag" "golang.org/x/xerrors" @@ -22,15 +29,9 @@ import ( logging "github.com/ipfs/go-log" goprocess "github.com/jbenet/goprocess" goprocessctx "github.com/jbenet/goprocess/context" - host "github.com/libp2p/go-libp2p-host" kb "github.com/libp2p/go-libp2p-kbucket" - inet "github.com/libp2p/go-libp2p-net" - peer "github.com/libp2p/go-libp2p-peer" - pstore "github.com/libp2p/go-libp2p-peerstore" - protocol "github.com/libp2p/go-libp2p-protocol" record "github.com/libp2p/go-libp2p-record" recpb "github.com/libp2p/go-libp2p-record/pb" - routing "github.com/libp2p/go-libp2p-routing" base32 "github.com/whyrusleeping/base32" ) @@ -41,11 +42,11 @@ var logger = logging.Logger("dht") const NumBootstrapQueries = 5 // IpfsDHT is an implementation of Kademlia with S/Kademlia modifications. -// It is used to implement the base IpfsRouting module. +// It is used to implement the base Routing module. type IpfsDHT struct { - host host.Host // the network services we need - self peer.ID // Local peer (yourself) - peerstore pstore.Peerstore // Peer Registry + host host.Host // the network services we need + self peer.ID // Local peer (yourself) + peerstore peerstore.Peerstore // Peer Registry datastore ds.Datastore // Local data @@ -71,7 +72,7 @@ type IpfsDHT struct { // guarantee, but we can use them to aid refactoring. var ( _ routing.ContentRouting = (*IpfsDHT)(nil) - _ routing.IpfsRouting = (*IpfsDHT)(nil) + _ routing.Routing = (*IpfsDHT)(nil) _ routing.PeerRouting = (*IpfsDHT)(nil) _ routing.PubKeyFetcher = (*IpfsDHT)(nil) _ routing.ValueStore = (*IpfsDHT)(nil) @@ -182,7 +183,7 @@ var errInvalidRecord = errors.New("received invalid record") // key. It returns either the value or a list of closer peers. // NOTE: It will update the dht's peerstore with any new addresses // it finds for the given peer. -func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.ID, key string) (*recpb.Record, []*pstore.PeerInfo, error) { +func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.ID, key string) (*recpb.Record, []*peer.AddrInfo, error) { pmes, err := dht.getValueSingle(ctx, p, key) if err != nil { @@ -278,12 +279,12 @@ func (dht *IpfsDHT) Update(ctx context.Context, p peer.ID) { } // FindLocal looks for a peer with a given ID connected to this dht and returns the peer and the table it was found in. -func (dht *IpfsDHT) FindLocal(id peer.ID) pstore.PeerInfo { +func (dht *IpfsDHT) FindLocal(id peer.ID) peer.AddrInfo { switch dht.host.Network().Connectedness(id) { - case inet.Connected, inet.CanConnect: + case network.Connected, network.CanConnect: return dht.peerstore.PeerInfo(id) default: - return pstore.PeerInfo{} + return peer.AddrInfo{} } } diff --git a/dht_bootstrap.go b/dht_bootstrap.go index b70d81b17..0dd188482 100644 --- a/dht_bootstrap.go +++ b/dht_bootstrap.go @@ -6,11 +6,11 @@ import ( "fmt" "time" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/routing" + u "github.com/ipfs/go-ipfs-util" - peer "github.com/libp2p/go-libp2p-peer" - pstore "github.com/libp2p/go-libp2p-peerstore" - routing "github.com/libp2p/go-libp2p-routing" - multiaddr "github.com/multiformats/go-multiaddr" + "github.com/multiformats/go-multiaddr" _ "github.com/multiformats/go-multiaddr-dns" ) @@ -112,7 +112,7 @@ func newRandomPeerId() peer.ID { } // Traverse the DHT toward the given ID. -func (dht *IpfsDHT) walk(ctx context.Context, target peer.ID) (pstore.PeerInfo, error) { +func (dht *IpfsDHT) walk(ctx context.Context, target peer.ID) (peer.AddrInfo, error) { // TODO: Extract the query action (traversal logic?) inside FindPeer, // don't actually call through the FindPeer machinery, which can return // things out of the peer store etc. diff --git a/dht_net.go b/dht_net.go index b8bfe848a..ce9e5de36 100644 --- a/dht_net.go +++ b/dht_net.go @@ -8,11 +8,15 @@ import ( "sync" "time" - ggio "github.com/gogo/protobuf/io" + "github.com/libp2p/go-libp2p-core/helpers" + "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-kad-dht/metrics" pb "github.com/libp2p/go-libp2p-kad-dht/pb" - inet "github.com/libp2p/go-libp2p-net" - peer "github.com/libp2p/go-libp2p-peer" + + ggio "github.com/gogo/protobuf/io" + "go.opencensus.io/stats" "go.opencensus.io/tag" ) @@ -55,8 +59,8 @@ func (w *bufferedDelimitedWriter) Flush() error { return w.Writer.Flush() } -// handleNewStream implements the inet.StreamHandler -func (dht *IpfsDHT) handleNewStream(s inet.Stream) { +// handleNewStream implements the network.StreamHandler +func (dht *IpfsDHT) handleNewStream(s network.Stream) { defer s.Reset() if dht.handleNewMessage(s) { // Gracefully close the stream for writes. @@ -65,9 +69,10 @@ func (dht *IpfsDHT) handleNewStream(s inet.Stream) { } // Returns true on orderly completion of writes (so we can Close the stream). -func (dht *IpfsDHT) handleNewMessage(s inet.Stream) bool { +func (dht *IpfsDHT) handleNewMessage(s network.Stream) bool { ctx := dht.ctx - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) + r := ggio.NewDelimitedReader(s, network.MessageSizeMax) + mPeer := s.Conn().RemotePeer() timer := time.AfterFunc(dhtStreamIdleTimeout, func() { s.Reset() }) @@ -242,7 +247,7 @@ func (dht *IpfsDHT) messageSenderForPeer(ctx context.Context, p peer.ID) (*messa } type messageSender struct { - s inet.Stream + s network.Stream r ggio.ReadCloser lk sync.Mutex p peer.ID @@ -286,7 +291,7 @@ func (ms *messageSender) prep(ctx context.Context) error { return err } - ms.r = ggio.NewDelimitedReader(nstr, inet.MessageSizeMax) + ms.r = ggio.NewDelimitedReader(nstr, network.MessageSizeMax) ms.s = nstr return nil @@ -322,7 +327,7 @@ func (ms *messageSender) SendMessage(ctx context.Context, pmes *pb.Message) erro logger.Event(ctx, "dhtSentMessage", ms.dht.self, ms.p, pmes) if ms.singleMes > streamReuseTries { - go inet.FullClose(ms.s) + go helpers.FullClose(ms.s) ms.s = nil } else if retry { ms.singleMes++ @@ -371,7 +376,7 @@ func (ms *messageSender) SendRequest(ctx context.Context, pmes *pb.Message) (*pb logger.Event(ctx, "dhtSentMessage", ms.dht.self, ms.p, pmes) if ms.singleMes > streamReuseTries { - go inet.FullClose(ms.s) + go helpers.FullClose(ms.s) ms.s = nil } else if retry { ms.singleMes++ diff --git a/dht_test.go b/dht_test.go index 1c73b5023..fc819067e 100644 --- a/dht_test.go +++ b/dht_test.go @@ -12,6 +12,10 @@ import ( "testing" "time" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/peerstore" + "github.com/libp2p/go-libp2p-core/routing" + multistream "github.com/multiformats/go-multistream" "golang.org/x/xerrors" @@ -25,14 +29,11 @@ import ( cid "github.com/ipfs/go-cid" u "github.com/ipfs/go-ipfs-util" kb "github.com/libp2p/go-libp2p-kbucket" - peer "github.com/libp2p/go-libp2p-peer" - pstore "github.com/libp2p/go-libp2p-peerstore" record "github.com/libp2p/go-libp2p-record" - routing "github.com/libp2p/go-libp2p-routing" swarmt "github.com/libp2p/go-libp2p-swarm/testing" + ci "github.com/libp2p/go-libp2p-testing/ci" + travisci "github.com/libp2p/go-libp2p-testing/ci/travis" bhost "github.com/libp2p/go-libp2p/p2p/host/basic" - ci "github.com/libp2p/go-testutil/ci" - travisci "github.com/libp2p/go-testutil/ci/travis" ma "github.com/multiformats/go-multiaddr" ) @@ -127,8 +128,8 @@ func connectNoSync(t *testing.T, ctx context.Context, a, b *IpfsDHT) { t.Fatal("peers setup incorrectly: no local address") } - a.peerstore.AddAddrs(idB, addrB, pstore.TempAddrTTL) - pi := pstore.PeerInfo{ID: idB} + a.peerstore.AddAddrs(idB, addrB, peerstore.TempAddrTTL) + pi := peer.AddrInfo{ID: idB} if err := a.host.Connect(ctx, pi); err != nil { t.Fatal(err) } @@ -1012,7 +1013,7 @@ func TestFindPeersConnectedToPeer(t *testing.T) { } // shouldFind := []peer.ID{peers[1], peers[3]} - var found []*pstore.PeerInfo + var found []*peer.AddrInfo for nextp := range pchan { found = append(found, nextp) } @@ -1056,14 +1057,14 @@ func TestConnectCollision(t *testing.T) { errs := make(chan error) go func() { - dhtA.peerstore.AddAddr(peerB, addrB, pstore.TempAddrTTL) - pi := pstore.PeerInfo{ID: peerB} + dhtA.peerstore.AddAddr(peerB, addrB, peerstore.TempAddrTTL) + pi := peer.AddrInfo{ID: peerB} err := dhtA.host.Connect(ctx, pi) errs <- err }() go func() { - dhtB.peerstore.AddAddr(peerA, addrA, pstore.TempAddrTTL) - pi := pstore.PeerInfo{ID: peerA} + dhtB.peerstore.AddAddr(peerA, addrA, peerstore.TempAddrTTL) + pi := peer.AddrInfo{ID: peerA} err := dhtB.host.Connect(ctx, pi) errs <- err }() @@ -1373,7 +1374,7 @@ func TestPing(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() ds := setupDHTS(t, ctx, 2) - ds[0].Host().Peerstore().AddAddrs(ds[1].PeerID(), ds[1].Host().Addrs(), pstore.AddressTTL) + ds[0].Host().Peerstore().AddAddrs(ds[1].PeerID(), ds[1].Host().Addrs(), peerstore.AddressTTL) assert.NoError(t, ds[0].Ping(context.Background(), ds[1].PeerID())) } @@ -1382,7 +1383,7 @@ func TestClientModeAtInit(t *testing.T) { defer cancel() pinger := setupDHT(ctx, t, false) client := setupDHT(ctx, t, true) - pinger.Host().Peerstore().AddAddrs(client.PeerID(), client.Host().Addrs(), pstore.AddressTTL) + pinger.Host().Peerstore().AddAddrs(client.PeerID(), client.Host().Addrs(), peerstore.AddressTTL) err := pinger.Ping(context.Background(), client.PeerID()) assert.True(t, xerrors.Is(err, multistream.ErrNotSupported)) } diff --git a/dial_queue.go b/dial_queue.go index 07adddf86..23bd352d1 100644 --- a/dial_queue.go +++ b/dial_queue.go @@ -6,7 +6,7 @@ import ( "sync" "time" - peer "github.com/libp2p/go-libp2p-peer" + "github.com/libp2p/go-libp2p-core/peer" queue "github.com/libp2p/go-libp2p-peerstore/queue" ) diff --git a/dial_queue_test.go b/dial_queue_test.go index ccc7b730a..e97bb9519 100644 --- a/dial_queue_test.go +++ b/dial_queue_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - peer "github.com/libp2p/go-libp2p-peer" + "github.com/libp2p/go-libp2p-core/peer" queue "github.com/libp2p/go-libp2p-peerstore/queue" ) diff --git a/ext_test.go b/ext_test.go index 1612d9802..cb0ac7634 100644 --- a/ext_test.go +++ b/ext_test.go @@ -6,13 +6,14 @@ import ( "testing" "time" + "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/routing" + ggio "github.com/gogo/protobuf/io" u "github.com/ipfs/go-ipfs-util" pb "github.com/libp2p/go-libp2p-kad-dht/pb" - inet "github.com/libp2p/go-libp2p-net" - pstore "github.com/libp2p/go-libp2p-peerstore" record "github.com/libp2p/go-libp2p-record" - routing "github.com/libp2p/go-libp2p-routing" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" ) @@ -35,7 +36,7 @@ func TestGetFailures(t *testing.T) { d.Update(ctx, hosts[1].ID()) // Reply with failures to every message - hosts[1].SetStreamHandler(d.protocols[0], func(s inet.Stream) { + hosts[1].SetStreamHandler(d.protocols[0], func(s network.Stream) { time.Sleep(400 * time.Millisecond) s.Close() }) @@ -58,10 +59,10 @@ func TestGetFailures(t *testing.T) { t.Log("Timeout test passed.") // Reply with failures to every message - hosts[1].SetStreamHandler(d.protocols[0], func(s inet.Stream) { + hosts[1].SetStreamHandler(d.protocols[0], func(s network.Stream) { defer s.Close() - pbr := ggio.NewDelimitedReader(s, inet.MessageSizeMax) + pbr := ggio.NewDelimitedReader(s, network.MessageSizeMax) pbw := ggio.NewDelimitedWriter(s) pmes := new(pb.Message) @@ -116,7 +117,7 @@ func TestGetFailures(t *testing.T) { } defer s.Close() - pbr := ggio.NewDelimitedReader(s, inet.MessageSizeMax) + pbr := ggio.NewDelimitedReader(s, network.MessageSizeMax) pbw := ggio.NewDelimitedWriter(s) if err := pbw.WriteMsg(&req); err != nil { @@ -160,10 +161,10 @@ func TestNotFound(t *testing.T) { // Reply with random peers to every message for _, host := range hosts { host := host // shadow loop var - host.SetStreamHandler(d.protocols[0], func(s inet.Stream) { + host.SetStreamHandler(d.protocols[0], func(s network.Stream) { defer s.Close() - pbr := ggio.NewDelimitedReader(s, inet.MessageSizeMax) + pbr := ggio.NewDelimitedReader(s, network.MessageSizeMax) pbw := ggio.NewDelimitedWriter(s) pmes := new(pb.Message) @@ -175,7 +176,7 @@ func TestNotFound(t *testing.T) { case pb.Message_GET_VALUE: resp := &pb.Message{Type: pmes.Type} - ps := []pstore.PeerInfo{} + ps := []peer.AddrInfo{} for i := 0; i < 7; i++ { p := hosts[rand.Intn(len(hosts))].ID() pi := host.Peerstore().PeerInfo(p) @@ -239,10 +240,10 @@ func TestLessThanKResponses(t *testing.T) { // Reply with random peers to every message for _, host := range hosts { host := host // shadow loop var - host.SetStreamHandler(d.protocols[0], func(s inet.Stream) { + host.SetStreamHandler(d.protocols[0], func(s network.Stream) { defer s.Close() - pbr := ggio.NewDelimitedReader(s, inet.MessageSizeMax) + pbr := ggio.NewDelimitedReader(s, network.MessageSizeMax) pbw := ggio.NewDelimitedWriter(s) pmes := new(pb.Message) @@ -255,7 +256,7 @@ func TestLessThanKResponses(t *testing.T) { pi := host.Peerstore().PeerInfo(hosts[1].ID()) resp := &pb.Message{ Type: pmes.Type, - CloserPeers: pb.PeerInfosToPBPeers(d.host.Network(), []pstore.PeerInfo{pi}), + CloserPeers: pb.PeerInfosToPBPeers(d.host.Network(), []peer.AddrInfo{pi}), } if err := pbw.WriteMsg(resp); err != nil { @@ -305,10 +306,10 @@ func TestMultipleQueries(t *testing.T) { // It would be nice to be able to just get a value and succeed but then // we'd need to deal with selectors and validators... - hosts[1].SetStreamHandler(d.protocols[0], func(s inet.Stream) { + hosts[1].SetStreamHandler(d.protocols[0], func(s network.Stream) { defer s.Close() - pbr := ggio.NewDelimitedReader(s, inet.MessageSizeMax) + pbr := ggio.NewDelimitedReader(s, network.MessageSizeMax) pbw := ggio.NewDelimitedWriter(s) pmes := new(pb.Message) @@ -321,7 +322,7 @@ func TestMultipleQueries(t *testing.T) { pi := hosts[1].Peerstore().PeerInfo(hosts[0].ID()) resp := &pb.Message{ Type: pmes.Type, - CloserPeers: pb.PeerInfosToPBPeers(d.host.Network(), []pstore.PeerInfo{pi}), + CloserPeers: pb.PeerInfosToPBPeers(d.host.Network(), []peer.AddrInfo{pi}), } if err := pbw.WriteMsg(resp); err != nil { diff --git a/go.mod b/go.mod index b396a7173..a29d27561 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,7 @@ module github.com/libp2p/go-libp2p-kad-dht require ( - github.com/davecgh/go-spew v1.1.1 // indirect github.com/gogo/protobuf v1.2.1 - github.com/golang/protobuf v1.3.1 // indirect github.com/hashicorp/golang-lru v0.5.1 github.com/ipfs/go-cid v0.0.2 github.com/ipfs/go-datastore v0.0.5 @@ -11,30 +9,20 @@ require ( github.com/ipfs/go-log v0.0.1 github.com/ipfs/go-todocounter v0.0.1 github.com/jbenet/goprocess v0.1.3 - github.com/libp2p/go-libp2p v0.0.30 - github.com/libp2p/go-libp2p-crypto v0.0.2 - github.com/libp2p/go-libp2p-host v0.0.3 - github.com/libp2p/go-libp2p-kbucket v0.1.1 - github.com/libp2p/go-libp2p-net v0.0.2 - github.com/libp2p/go-libp2p-peer v0.1.1 - github.com/libp2p/go-libp2p-peerstore v0.0.6 - github.com/libp2p/go-libp2p-protocol v0.0.1 - github.com/libp2p/go-libp2p-record v0.0.1 - github.com/libp2p/go-libp2p-routing v0.0.1 - github.com/libp2p/go-libp2p-swarm v0.0.6 - github.com/libp2p/go-libp2p-yamux v0.1.3 // indirect - github.com/libp2p/go-mplex v0.0.4 // indirect - github.com/libp2p/go-testutil v0.0.1 - github.com/libp2p/go-yamux v1.2.3 // indirect - github.com/mattn/go-colorable v0.1.2 // indirect + github.com/libp2p/go-libp2p v0.1.0 + github.com/libp2p/go-libp2p-core v0.0.1 + github.com/libp2p/go-libp2p-kbucket v0.2.0 + github.com/libp2p/go-libp2p-peerstore v0.1.0 + github.com/libp2p/go-libp2p-record v0.1.0 + github.com/libp2p/go-libp2p-routing v0.1.0 + github.com/libp2p/go-libp2p-swarm v0.1.0 + github.com/libp2p/go-libp2p-testing v0.0.3 github.com/mr-tron/base58 v1.1.2 github.com/multiformats/go-multiaddr v0.0.4 github.com/multiformats/go-multiaddr-dns v0.0.2 - github.com/multiformats/go-multistream v0.0.4 + github.com/multiformats/go-multistream v0.1.0 github.com/stretchr/testify v1.3.0 github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc go.opencensus.io v0.21.0 - golang.org/x/text v0.3.2 // indirect golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522 - gopkg.in/yaml.v2 v2.2.2 // indirect ) diff --git a/go.sum b/go.sum index 544b9447f..2a04aeb97 100644 --- a/go.sum +++ b/go.sum @@ -13,15 +13,11 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.2.1-0.20180108230905-e214231b295a h1:U0BbGfKnviqVBJQB4etvm+mKx53KfkumNLBt6YeF/0Q= -github.com/coreos/go-semver v0.2.1-0.20180108230905-e214231b295a/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgraph-io/badger v1.5.5-0.20190226225317-8115aed38f8f/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ= github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -36,8 +32,6 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0 h1:kbxbvI4Un1LUWKxufD+BiE6AEExYYgkQLQmLFqA1LFk= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= -github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -108,86 +102,57 @@ github.com/libp2p/go-buffer-pool v0.0.1 h1:9Rrn/H46cXjaA2HQ5Y8lyhOS1NhTkZ4yuEs2r github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ= github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= -github.com/libp2p/go-conn-security v0.0.1 h1:4kMMrqrt9EUNCNjX1xagSJC+bq16uqjMe9lk1KBMVNs= -github.com/libp2p/go-conn-security v0.0.1/go.mod h1:bGmu51N0KU9IEjX7kl2PQjgZa40JQWnayTvNMgD/vyk= -github.com/libp2p/go-conn-security-multistream v0.0.2 h1:Ykz0lnNjxk+0SdslUmlLNyrleqdpS1S/VW+dxFdt74Y= -github.com/libp2p/go-conn-security-multistream v0.0.2/go.mod h1:nc9vud7inQ+d6SO0I/6dSWrdMnHnzZNHeyUQqrAJulE= +github.com/libp2p/go-conn-security-multistream v0.1.0 h1:aqGmto+ttL/uJgX0JtQI0tD21CIEy5eYd1Hlp0juHY0= +github.com/libp2p/go-conn-security-multistream v0.1.0/go.mod h1:aw6eD7LOsHEX7+2hJkDxw1MteijaVcI+/eP2/x3J1xc= github.com/libp2p/go-flow-metrics v0.0.1 h1:0gxuFd2GuK7IIP5pKljLwps6TvcuYgvG7Atqi3INF5s= github.com/libp2p/go-flow-metrics v0.0.1/go.mod h1:Iv1GH0sG8DtYN3SVJ2eG221wMiNpZxBdp967ls1g+k8= -github.com/libp2p/go-libp2p v0.0.30 h1:mwCWAusLhRGUzZ/VaCatsrEQTsuWExmXqVcvGBV72EQ= -github.com/libp2p/go-libp2p v0.0.30/go.mod h1:XWT8FGHlhptAv1+3V/+J5mEpzyui/5bvFsNuWYs611A= -github.com/libp2p/go-libp2p-autonat v0.0.6/go.mod h1:uZneLdOkZHro35xIhpbtTzLlgYturpu4J5+0cZK3MqE= -github.com/libp2p/go-libp2p-blankhost v0.0.1 h1:/mZuuiwntNR8RywnCFlGHLKrKLYne+qciBpQXWqp5fk= -github.com/libp2p/go-libp2p-blankhost v0.0.1/go.mod h1:Ibpbw/7cPPYwFb7PACIWdvxxv0t0XCCI10t7czjAjTc= -github.com/libp2p/go-libp2p-circuit v0.0.9/go.mod h1:uU+IBvEQzCu953/ps7bYzC/D/R0Ho2A9LfKVVCatlqU= -github.com/libp2p/go-libp2p-crypto v0.0.1 h1:JNQd8CmoGTohO/akqrH16ewsqZpci2CbgYH/LmYl8gw= -github.com/libp2p/go-libp2p-crypto v0.0.1/go.mod h1:yJkNyDmO341d5wwXxDUGO0LykUVT72ImHNUqh5D/dBE= -github.com/libp2p/go-libp2p-crypto v0.0.2 h1:TTdJ4y6Uoa6NxQcuEaVkQfFRcQeCE2ReDk8Ok4I0Fyw= -github.com/libp2p/go-libp2p-crypto v0.0.2/go.mod h1:eETI5OUfBnvARGOHrJz2eWNyTUxEGZnBxMcbUjfIj4I= -github.com/libp2p/go-libp2p-discovery v0.0.5/go.mod h1:YtF20GUxjgoKZ4zmXj8j3Nb2TUSBHFlOCetzYdbZL5I= -github.com/libp2p/go-libp2p-host v0.0.1 h1:dnqusU+DheGcdxrE718kG4XgHNuL2n9eEv8Rg5zy8hQ= -github.com/libp2p/go-libp2p-host v0.0.1/go.mod h1:qWd+H1yuU0m5CwzAkvbSjqKairayEHdR5MMl7Cwa7Go= -github.com/libp2p/go-libp2p-host v0.0.3 h1:BB/1Z+4X0rjKP5lbQTmjEjLbDVbrcmLOlA6QDsN5/j4= -github.com/libp2p/go-libp2p-host v0.0.3/go.mod h1:Y/qPyA6C8j2coYyos1dfRm0I8+nvd4TGrDGt4tA7JR8= -github.com/libp2p/go-libp2p-interface-connmgr v0.0.1 h1:Q9EkNSLAOF+u90L88qmE9z/fTdjLh8OsJwGw74mkwk4= -github.com/libp2p/go-libp2p-interface-connmgr v0.0.1/go.mod h1:GarlRLH0LdeWcLnYM/SaBykKFl9U5JFnbBGruAk/D5k= -github.com/libp2p/go-libp2p-interface-connmgr v0.0.4 h1:/LngXETpII5qOD7YjAcQiIxhVtdAk/NQe5t9sC6BR0E= -github.com/libp2p/go-libp2p-interface-connmgr v0.0.4/go.mod h1:GarlRLH0LdeWcLnYM/SaBykKFl9U5JFnbBGruAk/D5k= -github.com/libp2p/go-libp2p-interface-connmgr v0.0.5 h1:KG/KNYL2tYzXAfMvQN5K1aAGTYSYUMJ1prgYa2/JI1E= -github.com/libp2p/go-libp2p-interface-connmgr v0.0.5/go.mod h1:GarlRLH0LdeWcLnYM/SaBykKFl9U5JFnbBGruAk/D5k= -github.com/libp2p/go-libp2p-interface-pnet v0.0.1 h1:7GnzRrBTJHEsofi1ahFdPN9Si6skwXQE9UqR2S+Pkh8= -github.com/libp2p/go-libp2p-interface-pnet v0.0.1/go.mod h1:el9jHpQAXK5dnTpKA4yfCNBZXvrzdOU75zz+C6ryp3k= -github.com/libp2p/go-libp2p-kbucket v0.1.1 h1:ZrvW3qCM+lAuv7nrNts/zfEiClq+GZe8OIzX4Vb3Dwo= -github.com/libp2p/go-libp2p-kbucket v0.1.1/go.mod h1:Y0iQDHRTk/ZgM8PC4jExoF+E4j+yXWwRkdldkMa5Xm4= -github.com/libp2p/go-libp2p-loggables v0.0.1 h1:HVww9oAnINIxbt69LJNkxD8lnbfgteXR97Xm4p3l9ps= -github.com/libp2p/go-libp2p-loggables v0.0.1/go.mod h1:lDipDlBNYbpyqyPX/KcoO+eq0sJYEVR2JgOexcivchg= -github.com/libp2p/go-libp2p-metrics v0.0.1 h1:yumdPC/P2VzINdmcKZd0pciSUCpou+s0lwYCjBbzQZU= -github.com/libp2p/go-libp2p-metrics v0.0.1/go.mod h1:jQJ95SXXA/K1VZi13h52WZMa9ja78zjyy5rspMsC/08= -github.com/libp2p/go-libp2p-mplex v0.1.1 h1:lSPS1VJ36P01gGO//KgcsmSah5uoC3X9r7WY5j+iP4c= -github.com/libp2p/go-libp2p-mplex v0.1.1/go.mod h1:KUQWpGkCzfV7UIpi8SKsAVxyBgz1c9R5EvxgnwLsb/I= +github.com/libp2p/go-libp2p v0.1.0 h1:8VXadcPNni74ODoZ+7326LMAppFYmz1fRQOUuT5iZvQ= +github.com/libp2p/go-libp2p v0.1.0/go.mod h1:6D/2OBauqLUoqcADOJpn9WbKqvaM07tDw68qHM0BxUM= +github.com/libp2p/go-libp2p-autonat v0.1.0/go.mod h1:1tLf2yXxiE/oKGtDwPYWTSYG3PtvYlJmg7NeVtPRqH8= +github.com/libp2p/go-libp2p-blankhost v0.1.1 h1:X919sCh+KLqJcNRApj43xCSiQRYqOSI88Fdf55ngf78= +github.com/libp2p/go-libp2p-blankhost v0.1.1/go.mod h1:pf2fvdLJPsC1FsVrNP3DUUvMzUts2dsLLBEpo1vW1ro= +github.com/libp2p/go-libp2p-circuit v0.1.0/go.mod h1:Ahq4cY3V9VJcHcn1SBXjr78AbFkZeIRmfunbA7pmFh8= +github.com/libp2p/go-libp2p-core v0.0.1 h1:HSTZtFIq/W5Ue43Zw+uWZyy2Vl5WtF0zDjKN8/DT/1I= +github.com/libp2p/go-libp2p-core v0.0.1/go.mod h1:g/VxnTZ/1ygHxH3dKok7Vno1VfpvGcGip57wjTU4fco= +github.com/libp2p/go-libp2p-crypto v0.1.0 h1:k9MFy+o2zGDNGsaoZl0MA3iZ75qXxr9OOoAZF+sD5OQ= +github.com/libp2p/go-libp2p-crypto v0.1.0/go.mod h1:sPUokVISZiy+nNuTTH/TY+leRSxnFj/2GLjtOTW90hI= +github.com/libp2p/go-libp2p-discovery v0.1.0/go.mod h1:4F/x+aldVHjHDHuX85x1zWoFTGElt8HnoDzwkFZm29g= +github.com/libp2p/go-libp2p-kbucket v0.2.0 h1:FB2a0VkOTNGTP5gu/I444u4WabNM9V1zCkQcWb7zajI= +github.com/libp2p/go-libp2p-kbucket v0.2.0/go.mod h1:JNymBToym3QXKBMKGy3m29+xprg0EVr/GJFHxFEdgh8= +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 h1:E1xaJBQnbSiTHGI1gaBKmKhu1TUKkErKJnE8iGvirYI= +github.com/libp2p/go-libp2p-mplex v0.2.1/go.mod h1:SC99Rxs8Vuzrf/6WhmH41kNn13TiYdAWNYHrwImKLnE= github.com/libp2p/go-libp2p-nat v0.0.4 h1:+KXK324yaY701On8a0aGjTnw8467kW3ExKcqW2wwmyw= github.com/libp2p/go-libp2p-nat v0.0.4/go.mod h1:N9Js/zVtAXqaeT99cXgTV9e75KpnWCvVOiGzlcHmBbY= -github.com/libp2p/go-libp2p-net v0.0.1 h1:xJ4Vh4yKF/XKb8fd1Ev0ebAGzVjMxXzrxG2kjtU+F5Q= -github.com/libp2p/go-libp2p-net v0.0.1/go.mod h1:Yt3zgmlsHOgUWSXmt5V/Jpz9upuJBE8EgNU9DrCcR8c= -github.com/libp2p/go-libp2p-net v0.0.2 h1:qP06u4TYXfl7uW/hzqPhlVVTSA2nw1B/bHBJaUnbh6M= -github.com/libp2p/go-libp2p-net v0.0.2/go.mod h1:Yt3zgmlsHOgUWSXmt5V/Jpz9upuJBE8EgNU9DrCcR8c= -github.com/libp2p/go-libp2p-netutil v0.0.1 h1:LgD6+skofkOx8z6odD9+MZHKjupv3ng1u6KRhaADTnA= -github.com/libp2p/go-libp2p-netutil v0.0.1/go.mod h1:GdusFvujWZI9Vt0X5BKqwWWmZFxecf9Gt03cKxm2f/Q= -github.com/libp2p/go-libp2p-peer v0.0.1 h1:0qwAOljzYewINrU+Kndoc+1jAL7vzY/oY2Go4DCGfyY= -github.com/libp2p/go-libp2p-peer v0.0.1/go.mod h1:nXQvOBbwVqoP+T5Y5nCjeH4sP9IX/J0AMzcDUVruVoo= -github.com/libp2p/go-libp2p-peer v0.1.1 h1:qGCWD1a+PyZcna6htMPo26jAtqirVnJ5NvBQIKV7rRY= -github.com/libp2p/go-libp2p-peer v0.1.1/go.mod h1:jkF12jGB4Gk/IOo+yomm+7oLWxF278F7UnrYUQ1Q8es= -github.com/libp2p/go-libp2p-peerstore v0.0.1 h1:twKovq8YK5trLrd3nB7PD2Zu9JcyAIdm7Bz9yBWjhq8= -github.com/libp2p/go-libp2p-peerstore v0.0.1/go.mod h1:RabLyPVJLuNQ+GFyoEkfi8H4Ti6k/HtZJ7YKgtSq+20= -github.com/libp2p/go-libp2p-peerstore v0.0.6 h1:RgX/djPFXqZGktW0j2eF4NAX0pzDsCot45jO2GewC+g= -github.com/libp2p/go-libp2p-peerstore v0.0.6/go.mod h1:RabLyPVJLuNQ+GFyoEkfi8H4Ti6k/HtZJ7YKgtSq+20= -github.com/libp2p/go-libp2p-protocol v0.0.1 h1:+zkEmZ2yFDi5adpVE3t9dqh/N9TbpFWywowzeEzBbLM= -github.com/libp2p/go-libp2p-protocol v0.0.1/go.mod h1:Af9n4PiruirSDjHycM1QuiMi/1VZNHYcK8cLgFJLZ4s= -github.com/libp2p/go-libp2p-record v0.0.1 h1:zN7AS3X46qmwsw5JLxdDuI43cH5UYwovKxHPjKBYQxw= -github.com/libp2p/go-libp2p-record v0.0.1/go.mod h1:grzqg263Rug/sRex85QrDOLntdFAymLDLm7lxMgU79Q= -github.com/libp2p/go-libp2p-routing v0.0.1 h1:hPMAWktf9rYi3ME4MG48qE7dq1ofJxiQbfdvpNntjhc= -github.com/libp2p/go-libp2p-routing v0.0.1/go.mod h1:N51q3yTr4Zdr7V8Jt2JIktVU+3xBBylx1MZeVA6t1Ys= -github.com/libp2p/go-libp2p-secio v0.0.3 h1:h3fPeDrej7bvvARnC2oSjAfcLZOaS4REZKgWCRQNpE4= -github.com/libp2p/go-libp2p-secio v0.0.3/go.mod h1:hS7HQ00MgLhRO/Wyu1bTX6ctJKhVpm+j2/S2A5UqYb0= -github.com/libp2p/go-libp2p-swarm v0.0.6 h1:gE0P/v2h+KEXtAi9YTw2UBOSODJ4m9VuuJ+ktc2LVUo= -github.com/libp2p/go-libp2p-swarm v0.0.6/go.mod h1:s5GZvzg9xXe8sbeESuFpjt8CJPTCa8mhEusweJqyFy8= -github.com/libp2p/go-libp2p-transport v0.0.1/go.mod h1:UzbUs9X+PHOSw7S3ZmeOxfnwaQY5vGDzZmKPod3N3tk= -github.com/libp2p/go-libp2p-transport v0.0.5 h1:pV6+UlRxyDpASSGD+60vMvdifSCby6JkJDfi+yUMHac= -github.com/libp2p/go-libp2p-transport v0.0.5/go.mod h1:StoY3sx6IqsP6XKoabsPnHCwqKXWUMWU7Rfcsubee/A= -github.com/libp2p/go-libp2p-transport-upgrader v0.0.4 h1:uGMOd14BL1oFlfb/cGfOxPjiTKBhzWV4aMjjoCF1Z1o= -github.com/libp2p/go-libp2p-transport-upgrader v0.0.4/go.mod h1:RGq+tupk+oj7PzL2kn/m1w6YXxcIAYJYeI90h6BGgUc= -github.com/libp2p/go-libp2p-yamux v0.1.2 h1:DgGItlrWi0j9y1OhRMC8qqL4zj2MEPWeKJTHb55R16Q= -github.com/libp2p/go-libp2p-yamux v0.1.2/go.mod h1:xUoV/RmYkg6BW/qGxA9XJyg+HzXFYkeXbnhjmnYzKp8= -github.com/libp2p/go-libp2p-yamux v0.1.3 h1:HmKvv2jWJ4GEm3iP7cEKjuw0POa6rK+Hcsu1FBKzpLc= -github.com/libp2p/go-libp2p-yamux v0.1.3/go.mod h1:VGSQVrqkh6y4nm0189qqxMtvyBft44MOYYPpYKXiVt4= -github.com/libp2p/go-maddr-filter v0.0.1 h1:apvYTg0aIxxQyBX+XHKOR+0+lYhGs1Yv+JmTH9nyl5I= -github.com/libp2p/go-maddr-filter v0.0.1/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q= +github.com/libp2p/go-libp2p-netutil v0.1.0 h1:zscYDNVEcGxyUpMd0JReUZTrpMfia8PmLKcKF72EAMQ= +github.com/libp2p/go-libp2p-netutil v0.1.0/go.mod h1:3Qv/aDqtMLTUyQeundkKsA+YCThNdbQD54k3TqjpbFU= +github.com/libp2p/go-libp2p-peer v0.2.0 h1:EQ8kMjaCUwt/Y5uLgjT8iY2qg0mGUT0N1zUjer50DsY= +github.com/libp2p/go-libp2p-peer v0.2.0/go.mod h1:RCffaCvUyW2CJmG2gAWVqwePwW7JMgxjsHm7+J5kjWY= +github.com/libp2p/go-libp2p-peerstore v0.1.0 h1:MKh7pRNPHSh1fLPj8u/M/s/napdmeNpoi9BRy9lPN0E= +github.com/libp2p/go-libp2p-peerstore v0.1.0/go.mod h1:2CeHkQsr8svp4fZ+Oi9ykN1HBb6u0MOvdJ7YIsmcwtY= +github.com/libp2p/go-libp2p-record v0.1.0 h1:wHwBGbFzymoIl69BpgwIu0O6ta3TXGcMPvHUAcodzRc= +github.com/libp2p/go-libp2p-record v0.1.0/go.mod h1:ujNc8iuE5dlKWVy6wuL6dd58t0n7xI4hAIl8pE6wu5Q= +github.com/libp2p/go-libp2p-routing v0.1.0 h1:hFnj3WR3E2tOcKaGpyzfP4gvFZ3t8JkQmbapN0Ct+oU= +github.com/libp2p/go-libp2p-routing v0.1.0/go.mod h1:zfLhI1RI8RLEzmEaaPwzonRvXeeSHddONWkcTcB54nE= +github.com/libp2p/go-libp2p-secio v0.1.0 h1:NNP5KLxuP97sE5Bu3iuwOWyT/dKEGMN5zSLMWdB7GTQ= +github.com/libp2p/go-libp2p-secio v0.1.0/go.mod h1:tMJo2w7h3+wN4pgU2LSYeiKPrfqBgkOsdiKK77hE7c8= +github.com/libp2p/go-libp2p-swarm v0.1.0 h1:HrFk2p0awrGEgch9JXK/qp/hfjqQfgNxpLWnCiWPg5s= +github.com/libp2p/go-libp2p-swarm v0.1.0/go.mod h1:wQVsCdjsuZoc730CgOvh5ox6K8evllckjebkdiY5ta4= +github.com/libp2p/go-libp2p-testing v0.0.2/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= +github.com/libp2p/go-libp2p-testing v0.0.3 h1:bdij4bKaaND7tCsaXVjRfYkMpvoOeKj9AVQGJllA6jM= +github.com/libp2p/go-libp2p-testing v0.0.3/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= +github.com/libp2p/go-libp2p-transport-upgrader v0.1.1 h1:PZMS9lhjK9VytzMCW3tWHAXtKXmlURSc3ZdvwEcKCzw= +github.com/libp2p/go-libp2p-transport-upgrader v0.1.1/go.mod h1:IEtA6or8JUbsV07qPW4r01GnTenLW4oi3lOPbUMGJJA= +github.com/libp2p/go-libp2p-yamux v0.2.0 h1:TSPZ5cMMz/wdoYsye/wU1TE4G3LDGMoeEN0xgnCKU/I= +github.com/libp2p/go-libp2p-yamux v0.2.0/go.mod h1:Db2gU+XfLpm6E4rG5uGCFX6uXA8MEXOxFcRoXUODaK8= github.com/libp2p/go-maddr-filter v0.0.4 h1:hx8HIuuwk34KePddrp2mM5ivgPkZ09JH4AvsALRbFUs= github.com/libp2p/go-maddr-filter v0.0.4/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q= github.com/libp2p/go-mplex v0.0.3 h1:YiMaevQcZtFU6DmKIF8xEO0vaui5kM5HJ1V1xkWQv14= github.com/libp2p/go-mplex v0.0.3/go.mod h1:pK5yMLmOoBR1pNCqDlA2GQrdAVTMkqFalaTWe7l4Yd0= -github.com/libp2p/go-mplex v0.0.4 h1:043XJ3Zr7/Oz5cfyUaJwxUZyP02TngTpt4oq8R5UizQ= -github.com/libp2p/go-mplex v0.0.4/go.mod h1:pK5yMLmOoBR1pNCqDlA2GQrdAVTMkqFalaTWe7l4Yd0= +github.com/libp2p/go-mplex v0.1.0 h1:/nBTy5+1yRyY82YaO6HXQRnO5IAGsXTjEJaR3LdTPc0= +github.com/libp2p/go-mplex v0.1.0/go.mod h1:SXgmdki2kwCUlCCbfGLEgHjC4pFqhTp0ZoV6aiKgxDU= github.com/libp2p/go-msgio v0.0.2 h1:ivPvEKHxmVkTClHzg6RXTYHqaJQ0V9cDbq+6lKb3UV0= github.com/libp2p/go-msgio v0.0.2/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= github.com/libp2p/go-nat v0.0.3 h1:l6fKV+p0Xa354EqQOQP+d8CivdLM4kl5GxC1hSc/UeI= @@ -198,26 +163,17 @@ github.com/libp2p/go-reuseport-transport v0.0.2 h1:WglMwyXyBu61CMkjCCtnmqNqnjib0 github.com/libp2p/go-reuseport-transport v0.0.2/go.mod h1:YkbSDrvjUVDL6b8XqriyA20obEtsW9BLkuOUyQAOCbs= github.com/libp2p/go-stream-muxer v0.0.1 h1:Ce6e2Pyu+b5MC1k3eeFtAax0pW4gc6MosYSLV05UeLw= github.com/libp2p/go-stream-muxer v0.0.1/go.mod h1:bAo8x7YkSpadMTbtTaxGVHWUQsR/l5MEaHbKaliuT14= -github.com/libp2p/go-stream-muxer-multistream v0.1.1 h1:DhHqb4nu1fQv/vQKeLAaZGmhLsUA4SF77IdYJiWE1d4= -github.com/libp2p/go-stream-muxer-multistream v0.1.1/go.mod h1:zmGdfkQ1AzOECIAcccoL8L//laqawOsO03zX8Sa+eGw= -github.com/libp2p/go-tcp-transport v0.0.4 h1:2iRu994wCT/iEz62F+c60FUoSkijNEQ0q2Itc+79XlQ= -github.com/libp2p/go-tcp-transport v0.0.4/go.mod h1:+E8HvC8ezEVOxIo3V5vCK9l1y/19K427vCzQ+xHKH/o= -github.com/libp2p/go-testutil v0.0.1 h1:Xg+O0G2HIMfHqBOBDcMS1iSZJ3GEcId4qOxCQvsGZHk= -github.com/libp2p/go-testutil v0.0.1/go.mod h1:iAcJc/DKJQanJ5ws2V+u5ywdL2n12X1WbbEG+Jjy69I= -github.com/libp2p/go-ws-transport v0.0.5/go.mod h1:Qbl4BxPfXXhhd/o0wcrgoaItHqA9tnZjoFZnxykuaXU= -github.com/libp2p/go-yamux v1.2.1 h1:VumHkMhJ2iFk1lzAeoDRgekiZSylGc6NnAEihVdBCiw= -github.com/libp2p/go-yamux v1.2.1/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= +github.com/libp2p/go-stream-muxer-multistream v0.2.0 h1:714bRJ4Zy9mdhyTLJ+ZKiROmAFwUHpeRidG+q7LTQOg= +github.com/libp2p/go-stream-muxer-multistream v0.2.0/go.mod h1:j9eyPol/LLRqT+GPLSxvimPhNph4sfYfMoDPd7HkzIc= +github.com/libp2p/go-tcp-transport v0.1.0 h1:IGhowvEqyMFknOar4FWCKSWE0zL36UFKQtiRQD60/8o= +github.com/libp2p/go-tcp-transport v0.1.0/go.mod h1:oJ8I5VXryj493DEJ7OsBieu8fcg2nHGctwtInJVpipc= +github.com/libp2p/go-ws-transport v0.1.0/go.mod h1:rjw1MG1LU9YDC6gzmwObkPd/Sqwhw7yT74kj3raBFuo= +github.com/libp2p/go-yamux v1.2.2 h1:s6J6o7+ajoQMjHe7BEnq+EynOj5D2EoG8CuQgL3F2vg= github.com/libp2p/go-yamux v1.2.2/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= -github.com/libp2p/go-yamux v1.2.3 h1:xX8A36vpXb59frIzWFdEgptLMsOANMFq2K7fPRlunYI= -github.com/libp2p/go-yamux v1.2.3/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= -github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.5 h1:tHXDdz1cpzGaovsTB+TVB8q90WEokoVmfMqoVcrLUgw= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/miekg/dns v1.1.12/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= @@ -225,19 +181,25 @@ github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16 h1:5W7KhL8HVF3XC github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= github.com/minio/sha256-simd v0.0.0-20190328051042-05b4dd3047e5 h1:l16XLUUJ34wIz+RIvLhSwGvLvKyy+W598b135bJN6mg= github.com/minio/sha256-simd v0.0.0-20190328051042-05b4dd3047e5/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= +github.com/minio/sha256-simd v0.1.0 h1:U41/2erhAKcmSI14xh/ZTUdBPOzDOIfS93ibzUSl8KM= +github.com/minio/sha256-simd v0.1.0/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= github.com/mr-tron/base58 v1.1.0 h1:Y51FGVJ91WBqCEabAi5OPUz38eAx8DakuAm5svLcsfQ= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= +github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/mr-tron/base58 v1.1.2 h1:ZEw4I2EgPKDJ2iEw0cNmLB3ROrEmkOtXIkaG7wZg+78= github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI= github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= github.com/multiformats/go-multiaddr v0.0.1 h1:/QUV3VBMDI6pi6xfiw7lr6xhDWWvQKn9udPn68kLSdY= github.com/multiformats/go-multiaddr v0.0.1/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= +github.com/multiformats/go-multiaddr v0.0.2/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= github.com/multiformats/go-multiaddr v0.0.4 h1:WgMSI84/eRLdbptXMkMWDXPjPq7SPLIgGUVm2eroyU4= github.com/multiformats/go-multiaddr v0.0.4/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= github.com/multiformats/go-multiaddr-dns v0.0.1/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= github.com/multiformats/go-multiaddr-dns v0.0.2 h1:/Bbsgsy3R6e3jf2qBahzNHzww6usYaZ0NhNH3sqdFS8= github.com/multiformats/go-multiaddr-dns v0.0.2/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= +github.com/multiformats/go-multiaddr-fmt v0.0.1 h1:5YjeOIzbX8OTKVaN72aOzGIYW7PnrZrnkDyOfAWRSMA= +github.com/multiformats/go-multiaddr-fmt v0.0.1/go.mod h1:aBYjqL4T/7j4Qx+R73XSv/8JsgnRFlf0w2KGLCmXl3Q= github.com/multiformats/go-multiaddr-net v0.0.1 h1:76O59E3FavvHqNg7jvzWzsPSW5JSi/ek0E4eiDVbg9g= github.com/multiformats/go-multiaddr-net v0.0.1/go.mod h1:nw6HSxNmCIQH27XPGBuX+d1tnvM7ihcFwHMSstNAVUU= github.com/multiformats/go-multibase v0.0.1 h1:PN9/v21eLywrFWdFNsFKaU04kLJzuYzmrJR+ubhT9qA= @@ -246,15 +208,17 @@ github.com/multiformats/go-multihash v0.0.1 h1:HHwN1K12I+XllBCrqKnhX949Orn4oawPk github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U= github.com/multiformats/go-multihash v0.0.5 h1:1wxmCvTXAifAepIMyF39vZinRw5sbqjPs/UIi93+uik= github.com/multiformats/go-multihash v0.0.5/go.mod h1:lt/HCbqlQwlPBz7lv0sQCdtfcMtlJvakRUn/0Ual8po= -github.com/multiformats/go-multistream v0.0.1 h1:JV4VfSdY9n7ECTtY59/TlSyFCzRILvYx4T4Ws8ZgihU= -github.com/multiformats/go-multistream v0.0.1/go.mod h1:fJTiDfXJVmItycydCnNx4+wSzZ5NwG2FEVAI30fiovg= -github.com/multiformats/go-multistream v0.0.4 h1:rNgWgFyzRSTI9L+xISrz7kN5MdNXoEcoIeeCH05wLKA= -github.com/multiformats/go-multistream v0.0.4/go.mod h1:fJTiDfXJVmItycydCnNx4+wSzZ5NwG2FEVAI30fiovg= +github.com/multiformats/go-multistream v0.1.0 h1:UpO6jrsjqs46mqAK3n6wKRYFhugss9ArzbyUzU+4wkQ= +github.com/multiformats/go-multistream v0.1.0/go.mod h1:fJTiDfXJVmItycydCnNx4+wSzZ5NwG2FEVAI30fiovg= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= +github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= @@ -290,12 +254,12 @@ golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b h1:+/WWzjwW6gidDJnMKWLKLX1gxn7irUTF1fLpQovfQ5M= golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25 h1:jsG6UpNLt9iAsb0S2AGW28DveNzzgmbXR+ENoPjUeIU= -golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 h1:p/H982KKEjUnLJkM3tt/LemDnOc1GiZL5FCVlORJ5zo= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPlt9tHXFfw5kvc0yqlxRPWo= +golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -328,10 +292,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522 h1:bhOzK9QyoD0ogCnFro1m2mz41+Ib0oOhfJnBp5MR4K4= @@ -351,6 +312,4 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/handlers.go b/handlers.go index 99ad280fc..aaeef7ca6 100644 --- a/handlers.go +++ b/handlers.go @@ -7,14 +7,16 @@ import ( "fmt" "time" + "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/peerstore" + pstore "github.com/libp2p/go-libp2p-peerstore" + proto "github.com/gogo/protobuf/proto" cid "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" u "github.com/ipfs/go-ipfs-util" pb "github.com/libp2p/go-libp2p-kad-dht/pb" - inet "github.com/libp2p/go-libp2p-net" - peer "github.com/libp2p/go-libp2p-peer" - pstore "github.com/libp2p/go-libp2p-peerstore" recpb "github.com/libp2p/go-libp2p-record/pb" base32 "github.com/whyrusleeping/base32" ) @@ -69,6 +71,7 @@ func (dht *IpfsDHT) handleGetValue(ctx context.Context, p peer.ID, pmes *pb.Mess // Find closest peer on given cluster to desired key and reply with that info closer := dht.betterPeersToQuery(pmes, p, CloserPeerCount) if len(closer) > 0 { + // TODO: pstore.PeerInfos should move to core (=> peerstore.AddrInfos). closerinfos := pstore.PeerInfos(dht.peerstore, closer) for _, pi := range closerinfos { logger.Debugf("handleGetValue returning closer peer: '%s'", pi.ID) @@ -265,7 +268,7 @@ func (dht *IpfsDHT) handleFindPeer(ctx context.Context, p peer.ID, pmes *pb.Mess // add a progressive, asynchronous `SearchPeer` function // and improve peer routing in the host. switch dht.host.Network().Connectedness(targetPid) { - case inet.Connected, inet.CanConnect: + case network.Connected, network.CanConnect: closest = append(closest, targetPid) } } @@ -276,9 +279,10 @@ func (dht *IpfsDHT) handleFindPeer(ctx context.Context, p peer.ID, pmes *pb.Mess return resp, nil } + // TODO: pstore.PeerInfos should move to core (=> peerstore.AddrInfos). closestinfos := pstore.PeerInfos(dht.peerstore, closest) // possibly an over-allocation but this array is temporary anyways. - withAddresses := make([]pstore.PeerInfo, 0, len(closestinfos)) + withAddresses := make([]peer.AddrInfo, 0, len(closestinfos)) for _, pi := range closestinfos { if len(pi.Addrs) > 0 { withAddresses = append(withAddresses, pi) @@ -321,6 +325,7 @@ func (dht *IpfsDHT) handleGetProviders(ctx context.Context, p peer.ID, pmes *pb. } if len(providers) > 0 { + // TODO: pstore.PeerInfos should move to core (=> peerstore.AddrInfos). infos := pstore.PeerInfos(dht.peerstore, providers) resp.ProviderPeers = pb.PeerInfosToPBPeers(dht.host.Network(), infos) logger.Debugf("%s have %d providers: %s", reqDesc, len(providers), infos) @@ -329,6 +334,7 @@ func (dht *IpfsDHT) handleGetProviders(ctx context.Context, p peer.ID, pmes *pb. // Also send closer peers. closer := dht.betterPeersToQuery(pmes, p, CloserPeerCount) if closer != nil { + // TODO: pstore.PeerInfos should move to core (=> peerstore.AddrInfos). infos := pstore.PeerInfos(dht.peerstore, closer) resp.CloserPeers = pb.PeerInfosToPBPeers(dht.host.Network(), infos) logger.Debugf("%s have %d closer peers: %s", reqDesc, len(closer), infos) @@ -368,7 +374,7 @@ func (dht *IpfsDHT) handleAddProvider(ctx context.Context, p peer.ID, pmes *pb.M logger.Debugf("received provider %s for %s (addrs: %s)", p, c, pi.Addrs) if pi.ID != dht.self { // don't add own addrs. // add the received addresses to our peerstore. - dht.peerstore.AddAddrs(pi.ID, pi.Addrs, pstore.ProviderAddrTTL) + dht.peerstore.AddAddrs(pi.ID, pi.Addrs, peerstore.ProviderAddrTTL) } dht.providers.AddProvider(ctx, c, p) } diff --git a/lookup.go b/lookup.go index 9d482292a..ea5bb31a1 100644 --- a/lookup.go +++ b/lookup.go @@ -5,11 +5,12 @@ import ( "fmt" "strings" + "github.com/libp2p/go-libp2p-core/peer" + cid "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log" pb "github.com/libp2p/go-libp2p-kad-dht/pb" kb "github.com/libp2p/go-libp2p-kbucket" - peer "github.com/libp2p/go-libp2p-peer" notif "github.com/libp2p/go-libp2p-routing/notifications" ) diff --git a/notif.go b/notif.go index fbcb073be..3af758492 100644 --- a/notif.go +++ b/notif.go @@ -1,7 +1,9 @@ package dht import ( - inet "github.com/libp2p/go-libp2p-net" + "github.com/libp2p/go-libp2p-core/helpers" + "github.com/libp2p/go-libp2p-core/network" + ma "github.com/multiformats/go-multiaddr" mstream "github.com/multiformats/go-multistream" ) @@ -13,7 +15,7 @@ func (nn *netNotifiee) DHT() *IpfsDHT { return (*IpfsDHT)(nn) } -func (nn *netNotifiee) Connected(n inet.Network, v inet.Conn) { +func (nn *netNotifiee) Connected(n network.Network, v network.Conn) { dht := nn.DHT() select { case <-dht.Process().Closing(): @@ -29,7 +31,7 @@ func (nn *netNotifiee) Connected(n inet.Network, v inet.Conn) { // notifications are serialized but it's nice to be consistent. dht.plk.Lock() defer dht.plk.Unlock() - if dht.host.Network().Connectedness(p) == inet.Connected { + if dht.host.Network().Connectedness(p) == network.Connected { dht.Update(dht.Context(), p) } return @@ -41,7 +43,7 @@ func (nn *netNotifiee) Connected(n inet.Network, v inet.Conn) { go nn.testConnection(v) } -func (nn *netNotifiee) testConnection(v inet.Conn) { +func (nn *netNotifiee) testConnection(v network.Conn) { dht := nn.DHT() p := v.RemotePeer() @@ -53,7 +55,7 @@ func (nn *netNotifiee) testConnection(v inet.Conn) { // Connection error return } - defer inet.FullClose(s) + defer helpers.FullClose(s) selected, err := mstream.SelectOneOf(dht.protocolStrs(), s) if err != nil { @@ -68,12 +70,12 @@ func (nn *netNotifiee) testConnection(v inet.Conn) { // event and add the peer to the routing table after removing it. dht.plk.Lock() defer dht.plk.Unlock() - if dht.host.Network().Connectedness(p) == inet.Connected { + if dht.host.Network().Connectedness(p) == network.Connected { dht.Update(dht.Context(), p) } } -func (nn *netNotifiee) Disconnected(n inet.Network, v inet.Conn) { +func (nn *netNotifiee) Disconnected(n network.Network, v network.Conn) { dht := nn.DHT() select { case <-dht.Process().Closing(): @@ -87,7 +89,7 @@ func (nn *netNotifiee) Disconnected(n inet.Network, v inet.Conn) { // we don't concurrently process a connect event. dht.plk.Lock() defer dht.plk.Unlock() - if dht.host.Network().Connectedness(p) == inet.Connected { + if dht.host.Network().Connectedness(p) == network.Connected { // We're still connected. return } @@ -110,7 +112,7 @@ func (nn *netNotifiee) Disconnected(n inet.Network, v inet.Conn) { }() } -func (nn *netNotifiee) OpenedStream(n inet.Network, v inet.Stream) {} -func (nn *netNotifiee) ClosedStream(n inet.Network, v inet.Stream) {} -func (nn *netNotifiee) Listen(n inet.Network, a ma.Multiaddr) {} -func (nn *netNotifiee) ListenClose(n inet.Network, a ma.Multiaddr) {} +func (nn *netNotifiee) OpenedStream(n network.Network, v network.Stream) {} +func (nn *netNotifiee) ClosedStream(n network.Network, v network.Stream) {} +func (nn *netNotifiee) Listen(n network.Network, a ma.Multiaddr) {} +func (nn *netNotifiee) ListenClose(n network.Network, a ma.Multiaddr) {} diff --git a/notify_test.go b/notify_test.go index 7df9ee4c9..3a15a8e82 100644 --- a/notify_test.go +++ b/notify_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - tu "github.com/libp2p/go-testutil" + tu "github.com/libp2p/go-libp2p-testing/etc" ) func TestNotifieeMultipleConn(t *testing.T) { diff --git a/opts/options.go b/opts/options.go index fc73da8b1..93ce6c0de 100644 --- a/opts/options.go +++ b/opts/options.go @@ -5,7 +5,7 @@ import ( ds "github.com/ipfs/go-datastore" dssync "github.com/ipfs/go-datastore/sync" - protocol "github.com/libp2p/go-libp2p-protocol" + protocol "github.com/libp2p/go-libp2p-core/protocol" record "github.com/libp2p/go-libp2p-record" ) diff --git a/pb/message.go b/pb/message.go index a2a41254c..d8fd27270 100644 --- a/pb/message.go +++ b/pb/message.go @@ -1,10 +1,10 @@ package dht_pb import ( + "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-libp2p-core/peer" + logging "github.com/ipfs/go-log" - inet "github.com/libp2p/go-libp2p-net" - peer "github.com/libp2p/go-libp2p-peer" - pstore "github.com/libp2p/go-libp2p-peerstore" b58 "github.com/mr-tron/base58/base58" ma "github.com/multiformats/go-multiaddr" ) @@ -12,8 +12,8 @@ import ( var log = logging.Logger("dht.pb") type PeerRoutingInfo struct { - pstore.PeerInfo - inet.Connectedness + peer.AddrInfo + network.Connectedness } // NewMessage constructs a new dht message with given type, key, and level @@ -40,7 +40,7 @@ func peerRoutingInfoToPBPeer(p PeerRoutingInfo) *Message_Peer { return pbp } -func peerInfoToPBPeer(p pstore.PeerInfo) *Message_Peer { +func peerInfoToPBPeer(p peer.AddrInfo) *Message_Peer { pbp := new(Message_Peer) pbp.Addrs = make([][]byte, len(p.Addrs)) @@ -51,9 +51,9 @@ func peerInfoToPBPeer(p pstore.PeerInfo) *Message_Peer { return pbp } -// PBPeerToPeer turns a *Message_Peer into its pstore.PeerInfo counterpart -func PBPeerToPeerInfo(pbp *Message_Peer) *pstore.PeerInfo { - return &pstore.PeerInfo{ +// PBPeerToPeer turns a *Message_Peer into its peer.AddrInfo counterpart +func PBPeerToPeerInfo(pbp *Message_Peer) *peer.AddrInfo { + return &peer.AddrInfo{ ID: peer.ID(pbp.GetId()), Addrs: pbp.Addresses(), } @@ -61,7 +61,7 @@ func PBPeerToPeerInfo(pbp *Message_Peer) *pstore.PeerInfo { // RawPeerInfosToPBPeers converts a slice of Peers into a slice of *Message_Peers, // ready to go out on the wire. -func RawPeerInfosToPBPeers(peers []pstore.PeerInfo) []*Message_Peer { +func RawPeerInfosToPBPeers(peers []peer.AddrInfo) []*Message_Peer { pbpeers := make([]*Message_Peer, len(peers)) for i, p := range peers { pbpeers[i] = peerInfoToPBPeer(p) @@ -72,8 +72,8 @@ func RawPeerInfosToPBPeers(peers []pstore.PeerInfo) []*Message_Peer { // PeersToPBPeers converts given []peer.Peer into a set of []*Message_Peer, // which can be written to a message and sent out. the key thing this function // does (in addition to PeersToPBPeers) is set the ConnectionType with -// information from the given inet.Network. -func PeerInfosToPBPeers(n inet.Network, peers []pstore.PeerInfo) []*Message_Peer { +// information from the given network.Network. +func PeerInfosToPBPeers(n network.Network, peers []peer.AddrInfo) []*Message_Peer { pbps := RawPeerInfosToPBPeers(peers) for i, pbp := range pbps { c := ConnectionType(n.Connectedness(peers[i].ID)) @@ -90,10 +90,10 @@ func PeerRoutingInfosToPBPeers(peers []PeerRoutingInfo) []*Message_Peer { return pbpeers } -// PBPeersToPeerInfos converts given []*Message_Peer into []pstore.PeerInfo +// PBPeersToPeerInfos converts given []*Message_Peer into []peer.AddrInfo // Invalid addresses will be silently omitted. -func PBPeersToPeerInfos(pbps []*Message_Peer) []*pstore.PeerInfo { - peers := make([]*pstore.PeerInfo, 0, len(pbps)) +func PBPeersToPeerInfos(pbps []*Message_Peer) []*peer.AddrInfo { + peers := make([]*peer.AddrInfo, 0, len(pbps)) for _, pbp := range pbps { peers = append(peers, PBPeerToPeerInfo(pbp)) } @@ -149,35 +149,35 @@ func (m *Message) Loggable() map[string]interface{} { } // ConnectionType returns a Message_ConnectionType associated with the -// inet.Connectedness. -func ConnectionType(c inet.Connectedness) Message_ConnectionType { +// network.Connectedness. +func ConnectionType(c network.Connectedness) Message_ConnectionType { switch c { default: return Message_NOT_CONNECTED - case inet.NotConnected: + case network.NotConnected: return Message_NOT_CONNECTED - case inet.Connected: + case network.Connected: return Message_CONNECTED - case inet.CanConnect: + case network.CanConnect: return Message_CAN_CONNECT - case inet.CannotConnect: + case network.CannotConnect: return Message_CANNOT_CONNECT } } -// Connectedness returns an inet.Connectedness associated with the +// Connectedness returns an network.Connectedness associated with the // Message_ConnectionType. -func Connectedness(c Message_ConnectionType) inet.Connectedness { +func Connectedness(c Message_ConnectionType) network.Connectedness { switch c { default: - return inet.NotConnected + return network.NotConnected case Message_NOT_CONNECTED: - return inet.NotConnected + return network.NotConnected case Message_CONNECTED: - return inet.Connected + return network.Connected case Message_CAN_CONNECT: - return inet.CanConnect + return network.CanConnect case Message_CANNOT_CONNECT: - return inet.CannotConnect + return network.CannotConnect } } diff --git a/providers/providers.go b/providers/providers.go index fd696c30f..ec44cc511 100644 --- a/providers/providers.go +++ b/providers/providers.go @@ -7,6 +7,8 @@ import ( "strings" "time" + "github.com/libp2p/go-libp2p-core/peer" + lru "github.com/hashicorp/golang-lru/simplelru" cid "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" @@ -15,7 +17,6 @@ import ( logging "github.com/ipfs/go-log" goprocess "github.com/jbenet/goprocess" goprocessctx "github.com/jbenet/goprocess/context" - peer "github.com/libp2p/go-libp2p-peer" base32 "github.com/whyrusleeping/base32" ) diff --git a/providers/providers_test.go b/providers/providers_test.go index aacb2d960..58756c55c 100644 --- a/providers/providers_test.go +++ b/providers/providers_test.go @@ -8,12 +8,13 @@ import ( "testing" "time" + "github.com/libp2p/go-libp2p-core/peer" + cid "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" dsq "github.com/ipfs/go-datastore/query" dssync "github.com/ipfs/go-datastore/sync" u "github.com/ipfs/go-ipfs-util" - peer "github.com/libp2p/go-libp2p-peer" // // used by TestLargeProvidersSet: do not remove // lds "github.com/ipfs/go-ds-leveldb" diff --git a/query.go b/query.go index 297fcc817..c0211a56e 100644 --- a/query.go +++ b/query.go @@ -5,17 +5,18 @@ import ( "errors" "sync" + "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-libp2p-core/peer" + logging "github.com/ipfs/go-log" todoctr "github.com/ipfs/go-todocounter" process "github.com/jbenet/goprocess" ctxproc "github.com/jbenet/goprocess/context" kb "github.com/libp2p/go-libp2p-kbucket" - inet "github.com/libp2p/go-libp2p-net" - peer "github.com/libp2p/go-libp2p-peer" - pset "github.com/libp2p/go-libp2p-peer/peerset" - pstore "github.com/libp2p/go-libp2p-peerstore" + + pstore "github.com/libp2p/go-libp2p-core/peerstore" + "github.com/libp2p/go-libp2p-core/routing" queue "github.com/libp2p/go-libp2p-peerstore/queue" - routing "github.com/libp2p/go-libp2p-routing" notif "github.com/libp2p/go-libp2p-routing/notifications" ) @@ -32,12 +33,12 @@ type dhtQuery struct { } type dhtQueryResult struct { - peer *pstore.PeerInfo // FindPeer - closerPeers []*pstore.PeerInfo // * + peer *peer.AddrInfo // FindPeer + closerPeers []*peer.AddrInfo // * success bool - finalSet *pset.PeerSet - queriedSet *pset.PeerSet + finalSet *peer.Set + queriedSet *peer.Set } // constructs query @@ -79,8 +80,8 @@ func (q *dhtQuery) Run(ctx context.Context, peers []peer.ID) (*dhtQueryResult, e type dhtQueryRunner struct { query *dhtQuery // query to run - peersSeen *pset.PeerSet // all peers queried. prevent querying same peer 2x - peersQueried *pset.PeerSet // peers successfully connected to and queried + peersSeen *peer.Set // all peers queried. prevent querying same peer 2x + peersQueried *peer.Set // peers successfully connected to and queried peersDialed *dialQueue // peers we have dialed to peersToQuery *queue.ChanQueue // peers remaining to be queried peersRemaining todoctr.Counter // peersToQuery + currently processing @@ -103,8 +104,8 @@ func newQueryRunner(q *dhtQuery) *dhtQueryRunner { r := &dhtQueryRunner{ query: q, peersRemaining: todoctr.NewSyncCounter(), - peersSeen: pset.New(), - peersQueried: pset.New(), + peersSeen: peer.NewSet(), + peersQueried: peer.NewSet(), rateLimit: make(chan struct{}, q.concurrency), peersToQuery: peersToQuery, proc: proc, @@ -237,7 +238,7 @@ func (r *dhtQueryRunner) spawnWorkers(proc process.Process) { func (r *dhtQueryRunner) dialPeer(ctx context.Context, p peer.ID) error { // short-circuit if we're already connected. - if r.query.dht.host.Network().Connectedness(p) == inet.Connected { + if r.query.dht.host.Network().Connectedness(p) == network.Connected { return nil } @@ -247,7 +248,7 @@ func (r *dhtQueryRunner) dialPeer(ctx context.Context, p peer.ID) error { ID: p, }) - pi := pstore.PeerInfo{ID: p} + pi := peer.AddrInfo{ID: p} if err := r.query.dht.host.Connect(ctx, pi); err != nil { logger.Debugf("error connecting: %s", err) notif.PublishQueryEvent(r.runCtx, ¬if.QueryEvent{ diff --git a/records.go b/records.go index 5e508dbaf..5f641b056 100644 --- a/records.go +++ b/records.go @@ -5,9 +5,10 @@ import ( "fmt" "time" - ci "github.com/libp2p/go-libp2p-crypto" - peer "github.com/libp2p/go-libp2p-peer" - routing "github.com/libp2p/go-libp2p-routing" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/routing" + + ci "github.com/libp2p/go-libp2p-core/crypto" ) // MaxRecordAge specifies the maximum time that any node will hold onto a record diff --git a/records_test.go b/records_test.go index efe773920..cf0dee969 100644 --- a/records_test.go +++ b/records_test.go @@ -6,11 +6,12 @@ import ( "testing" "time" + ci "github.com/libp2p/go-libp2p-core/crypto" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/routing" + u "github.com/ipfs/go-ipfs-util" - ci "github.com/libp2p/go-libp2p-crypto" - peer "github.com/libp2p/go-libp2p-peer" record "github.com/libp2p/go-libp2p-record" - routing "github.com/libp2p/go-libp2p-routing" ) // Check that GetPublicKey() correctly extracts a public key diff --git a/routing.go b/routing.go index 5be767209..9050ef513 100644 --- a/routing.go +++ b/routing.go @@ -8,19 +8,17 @@ import ( "sync" "time" + "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p-core/peerstore" + "github.com/libp2p/go-libp2p-core/routing" + cid "github.com/ipfs/go-cid" u "github.com/ipfs/go-ipfs-util" logging "github.com/ipfs/go-log" pb "github.com/libp2p/go-libp2p-kad-dht/pb" kb "github.com/libp2p/go-libp2p-kbucket" - inet "github.com/libp2p/go-libp2p-net" - peer "github.com/libp2p/go-libp2p-peer" - pset "github.com/libp2p/go-libp2p-peer/peerset" - pstore "github.com/libp2p/go-libp2p-peerstore" record "github.com/libp2p/go-libp2p-record" - routing "github.com/libp2p/go-libp2p-routing" - notif "github.com/libp2p/go-libp2p-routing/notifications" - ropts "github.com/libp2p/go-libp2p-routing/options" ) // asyncQueryBuffer is the size of buffered channels in async queries. This @@ -35,7 +33,7 @@ var asyncQueryBuffer = 10 // PutValue adds value corresponding to given Key. // This is the top level "Store" operation of the DHT -func (dht *IpfsDHT) PutValue(ctx context.Context, key string, value []byte, opts ...ropts.Option) (err error) { +func (dht *IpfsDHT) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) (err error) { eip := logger.EventBegin(ctx, "PutValue") defer func() { eip.Append(loggableKey(key)) @@ -88,8 +86,8 @@ func (dht *IpfsDHT) PutValue(ctx context.Context, key string, value []byte, opts ctx, cancel := context.WithCancel(ctx) defer cancel() defer wg.Done() - notif.PublishQueryEvent(ctx, ¬if.QueryEvent{ - Type: notif.Value, + routing.PublishQueryEvent(ctx, &routing.QueryEvent{ + Type: routing.Value, ID: p, }) @@ -110,7 +108,7 @@ type RecvdVal struct { } // GetValue searches for the value corresponding to given Key. -func (dht *IpfsDHT) GetValue(ctx context.Context, key string, opts ...ropts.Option) (_ []byte, err error) { +func (dht *IpfsDHT) GetValue(ctx context.Context, key string, opts ...routing.Option) (_ []byte, err error) { eip := logger.EventBegin(ctx, "GetValue") defer func() { eip.Append(loggableKey(key)) @@ -121,7 +119,7 @@ func (dht *IpfsDHT) GetValue(ctx context.Context, key string, opts ...ropts.Opti }() // apply defaultQuorum if relevant - var cfg ropts.Options + var cfg routing.Options if err := cfg.Apply(opts...); err != nil { return nil, err } @@ -148,8 +146,8 @@ func (dht *IpfsDHT) GetValue(ctx context.Context, key string, opts ...ropts.Opti return best, nil } -func (dht *IpfsDHT) SearchValue(ctx context.Context, key string, opts ...ropts.Option) (<-chan []byte, error) { - var cfg ropts.Options +func (dht *IpfsDHT) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error) { + var cfg routing.Options if err := cfg.Apply(opts...); err != nil { return nil, err } @@ -316,8 +314,8 @@ func (dht *IpfsDHT) getValues(ctx context.Context, key string, nvals int) (<-cha // setup the Query parent := ctx query := dht.newQuery(key, func(ctx context.Context, p peer.ID) (*dhtQueryResult, error) { - notif.PublishQueryEvent(parent, ¬if.QueryEvent{ - Type: notif.SendingQuery, + routing.PublishQueryEvent(parent, &routing.QueryEvent{ + Type: routing.SendingQuery, ID: p, }) @@ -327,8 +325,8 @@ func (dht *IpfsDHT) getValues(ctx context.Context, key string, nvals int) (<-cha // in this case, they responded with nothing, // still send a notification so listeners can know the // request has completed 'successfully' - notif.PublishQueryEvent(parent, ¬if.QueryEvent{ - Type: notif.PeerResponse, + routing.PublishQueryEvent(parent, &routing.QueryEvent{ + Type: routing.PeerResponse, ID: p, }) return nil, err @@ -362,8 +360,8 @@ func (dht *IpfsDHT) getValues(ctx context.Context, key string, nvals int) (<-cha valslock.Unlock() } - notif.PublishQueryEvent(parent, ¬if.QueryEvent{ - Type: notif.PeerResponse, + routing.PublishQueryEvent(parent, &routing.QueryEvent{ + Type: routing.PeerResponse, ID: p, Responses: peers, }) @@ -436,7 +434,7 @@ func (dht *IpfsDHT) Provide(ctx context.Context, key cid.Cid, brdcst bool) (err return nil } func (dht *IpfsDHT) makeProvRecord(skey cid.Cid) (*pb.Message, error) { - pi := pstore.PeerInfo{ + pi := peer.AddrInfo{ ID: dht.self, Addrs: dht.host.Addrs(), } @@ -448,13 +446,13 @@ func (dht *IpfsDHT) makeProvRecord(skey cid.Cid) (*pb.Message, error) { } pmes := pb.NewMessage(pb.Message_ADD_PROVIDER, skey.Bytes(), 0) - pmes.ProviderPeers = pb.RawPeerInfosToPBPeers([]pstore.PeerInfo{pi}) + pmes.ProviderPeers = pb.RawPeerInfosToPBPeers([]peer.AddrInfo{pi}) return pmes, nil } // FindProviders searches until the context expires. -func (dht *IpfsDHT) FindProviders(ctx context.Context, c cid.Cid) ([]pstore.PeerInfo, error) { - var providers []pstore.PeerInfo +func (dht *IpfsDHT) FindProviders(ctx context.Context, c cid.Cid) ([]peer.AddrInfo, error) { + var providers []peer.AddrInfo for p := range dht.FindProvidersAsync(ctx, c, KValue) { providers = append(providers, p) } @@ -464,18 +462,18 @@ func (dht *IpfsDHT) FindProviders(ctx context.Context, c cid.Cid) ([]pstore.Peer // FindProvidersAsync is the same thing as FindProviders, but returns a channel. // Peers will be returned on the channel as soon as they are found, even before // the search query completes. -func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan pstore.PeerInfo { +func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan peer.AddrInfo { logger.Event(ctx, "findProviders", key) - peerOut := make(chan pstore.PeerInfo, count) + peerOut := make(chan peer.AddrInfo, count) go dht.findProvidersAsyncRoutine(ctx, key, count, peerOut) return peerOut } -func (dht *IpfsDHT) findProvidersAsyncRoutine(ctx context.Context, key cid.Cid, count int, peerOut chan pstore.PeerInfo) { +func (dht *IpfsDHT) findProvidersAsyncRoutine(ctx context.Context, key cid.Cid, count int, peerOut chan peer.AddrInfo) { defer logger.EventBegin(ctx, "findProvidersAsync", key).Done() defer close(peerOut) - ps := pset.NewLimited(count) + ps := peer.NewLimitedSet(count) provs := dht.providers.GetProviders(ctx, key) for _, p := range provs { // NOTE: Assuming that this list of peers is unique @@ -497,8 +495,8 @@ func (dht *IpfsDHT) findProvidersAsyncRoutine(ctx context.Context, key cid.Cid, peers := dht.routingTable.NearestPeers(kb.ConvertKey(key.KeyString()), AlphaValue) if len(peers) == 0 { - notif.PublishQueryEvent(ctx, ¬if.QueryEvent{ - Type: notif.QueryError, + routing.PublishQueryEvent(ctx, &routing.QueryEvent{ + Type: routing.QueryError, Extra: kb.ErrLookupFailure.Error(), }) return @@ -507,8 +505,8 @@ func (dht *IpfsDHT) findProvidersAsyncRoutine(ctx context.Context, key cid.Cid, // setup the Query parent := ctx query := dht.newQuery(key.KeyString(), func(ctx context.Context, p peer.ID) (*dhtQueryResult, error) { - notif.PublishQueryEvent(parent, ¬if.QueryEvent{ - Type: notif.SendingQuery, + routing.PublishQueryEvent(parent, &routing.QueryEvent{ + Type: routing.SendingQuery, ID: p, }) pmes, err := dht.findProvidersSingle(ctx, p, key) @@ -523,7 +521,7 @@ func (dht *IpfsDHT) findProvidersAsyncRoutine(ctx context.Context, key cid.Cid, // Add unique providers from request, up to 'count' for _, prov := range provs { if prov.ID != dht.self { - dht.peerstore.AddAddrs(prov.ID, prov.Addrs, pstore.TempAddrTTL) + dht.peerstore.AddAddrs(prov.ID, prov.Addrs, peerstore.TempAddrTTL) } logger.Debugf("got provider: %s", prov) if ps.TryAdd(prov.ID) { @@ -546,8 +544,8 @@ func (dht *IpfsDHT) findProvidersAsyncRoutine(ctx context.Context, key cid.Cid, clpeers := pb.PBPeersToPeerInfos(closer) logger.Debugf("got closer peers: %d %s", len(clpeers), clpeers) - notif.PublishQueryEvent(parent, ¬if.QueryEvent{ - Type: notif.PeerResponse, + routing.PublishQueryEvent(parent, &routing.QueryEvent{ + Type: routing.PeerResponse, ID: p, Responses: clpeers, }) @@ -567,15 +565,15 @@ func (dht *IpfsDHT) findProvidersAsyncRoutine(ctx context.Context, key cid.Cid, // replace problematic error with something that won't crash the daemon err = fmt.Errorf("") } - notif.PublishQueryEvent(ctx, ¬if.QueryEvent{ - Type: notif.QueryError, + routing.PublishQueryEvent(ctx, &routing.QueryEvent{ + Type: routing.QueryError, Extra: err.Error(), }) } } // FindPeer searches for a peer with given ID. -func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (_ pstore.PeerInfo, err error) { +func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (_ peer.AddrInfo, err error) { eip := logger.EventBegin(ctx, "FindPeer", id) defer func() { if err != nil { @@ -591,7 +589,7 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (_ pstore.PeerInfo peers := dht.routingTable.NearestPeers(kb.ConvertPeerID(id), AlphaValue) if len(peers) == 0 { - return pstore.PeerInfo{}, kb.ErrLookupFailure + return peer.AddrInfo{}, kb.ErrLookupFailure } // Sanity... @@ -605,8 +603,8 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (_ pstore.PeerInfo // setup the Query parent := ctx query := dht.newQuery(string(id), func(ctx context.Context, p peer.ID) (*dhtQueryResult, error) { - notif.PublishQueryEvent(parent, ¬if.QueryEvent{ - Type: notif.SendingQuery, + routing.PublishQueryEvent(parent, &routing.QueryEvent{ + Type: routing.SendingQuery, ID: p, }) @@ -628,8 +626,8 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (_ pstore.PeerInfo } } - notif.PublishQueryEvent(parent, ¬if.QueryEvent{ - Type: notif.PeerResponse, + routing.PublishQueryEvent(parent, &routing.QueryEvent{ + Type: routing.PeerResponse, ID: p, Responses: clpeerInfos, }) @@ -640,21 +638,21 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (_ pstore.PeerInfo // run it! result, err := query.Run(ctx, peers) if err != nil { - return pstore.PeerInfo{}, err + return peer.AddrInfo{}, err } logger.Debugf("FindPeer %v %v", id, result.success) if result.peer.ID == "" { - return pstore.PeerInfo{}, routing.ErrNotFound + return peer.AddrInfo{}, routing.ErrNotFound } return *result.peer, nil } // FindPeersConnectedToPeer searches for peers directly connected to a given peer. -func (dht *IpfsDHT) FindPeersConnectedToPeer(ctx context.Context, id peer.ID) (<-chan *pstore.PeerInfo, error) { +func (dht *IpfsDHT) FindPeersConnectedToPeer(ctx context.Context, id peer.ID) (<-chan *peer.AddrInfo, error) { - peerchan := make(chan *pstore.PeerInfo, asyncQueryBuffer) + peerchan := make(chan *peer.AddrInfo, asyncQueryBuffer) peersSeen := make(map[peer.ID]struct{}) var peersSeenMx sync.Mutex @@ -671,7 +669,7 @@ func (dht *IpfsDHT) FindPeersConnectedToPeer(ctx context.Context, id peer.ID) (< return nil, err } - var clpeers []*pstore.PeerInfo + var clpeers []*peer.AddrInfo closer := pmes.GetCloserPeers() for _, pbp := range closer { pi := pb.PBPeerToPeerInfo(pbp) @@ -686,7 +684,7 @@ func (dht *IpfsDHT) FindPeersConnectedToPeer(ctx context.Context, id peer.ID) (< peersSeenMx.Unlock() // if peer is connected, send it to our client. - if pb.Connectedness(pbp.Connection) == inet.Connected { + if pb.Connectedness(pbp.Connection) == network.Connected { select { case <-ctx.Done(): return nil, ctx.Err() @@ -696,7 +694,7 @@ func (dht *IpfsDHT) FindPeersConnectedToPeer(ctx context.Context, id peer.ID) (< // if peer is the peer we're looking for, don't bother querying it. // TODO maybe query it? - if pb.Connectedness(pbp.Connection) != inet.Connected { + if pb.Connectedness(pbp.Connection) != network.Connected { clpeers = append(clpeers, pi) } } diff --git a/routing_options.go b/routing_options.go index 46083ea56..591ce54c4 100644 --- a/routing_options.go +++ b/routing_options.go @@ -1,8 +1,6 @@ package dht -import ( - ropts "github.com/libp2p/go-libp2p-routing/options" -) +import "github.com/libp2p/go-libp2p-core/routing" type quorumOptionKey struct{} @@ -12,8 +10,8 @@ const defaultQuorum = 16 // values from before returning the best one. // // Default: 16 -func Quorum(n int) ropts.Option { - return func(opts *ropts.Options) error { +func Quorum(n int) routing.Option { + return func(opts *routing.Options) error { if opts.Other == nil { opts.Other = make(map[interface{}]interface{}, 1) } @@ -22,7 +20,7 @@ func Quorum(n int) ropts.Option { } } -func getQuorum(opts *ropts.Options, ndefault int) int { +func getQuorum(opts *routing.Options, ndefault int) int { responsesNeeded, ok := opts.Other[quorumOptionKey{}].(int) if !ok { responsesNeeded = ndefault