From 9e002de8e0bfd7118deb3a446e7321f381a40d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Mon, 27 May 2019 00:22:15 +0100 Subject: [PATCH] migrate to consolidated types. --- p2p/net/gostream/addr.go | 2 +- p2p/net/gostream/conn.go | 15 ++++++++------- p2p/net/gostream/gostream_test.go | 9 +++++---- p2p/net/gostream/listener.go | 12 ++++++------ 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/p2p/net/gostream/addr.go b/p2p/net/gostream/addr.go index db3b25c50f..9546c0d722 100644 --- a/p2p/net/gostream/addr.go +++ b/p2p/net/gostream/addr.go @@ -1,6 +1,6 @@ package gostream -import peer "github.com/libp2p/go-libp2p-peer" +import "github.com/libp2p/go-libp2p-core/peer" // addr implements net.Addr and holds a libp2p peer ID. type addr struct{ id peer.ID } diff --git a/p2p/net/gostream/conn.go b/p2p/net/gostream/conn.go index dc5050ffaa..8ecc24b7e8 100644 --- a/p2p/net/gostream/conn.go +++ b/p2p/net/gostream/conn.go @@ -5,20 +5,21 @@ import ( "net" "time" - host "github.com/libp2p/go-libp2p-host" - pnet "github.com/libp2p/go-libp2p-net" - peer "github.com/libp2p/go-libp2p-peer" - protocol "github.com/libp2p/go-libp2p-protocol" + "github.com/libp2p/go-libp2p-core/helpers" + "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/protocol" ) // conn is an implementation of net.Conn which wraps // libp2p streams. type conn struct { - s pnet.Stream + s network.Stream } // newConn creates a conn given a libp2p stream -func newConn(s pnet.Stream) net.Conn { +func newConn(s network.Stream) net.Conn { return &conn{s} } @@ -39,7 +40,7 @@ func (c *conn) Close() error { c.s.Reset() return err } - go pnet.AwaitEOF(c.s) + go helpers.AwaitEOF(c.s) return nil } diff --git a/p2p/net/gostream/gostream_test.go b/p2p/net/gostream/gostream_test.go index cdbd5be124..b74a85a474 100644 --- a/p2p/net/gostream/gostream_test.go +++ b/p2p/net/gostream/gostream_test.go @@ -6,10 +6,11 @@ import ( "testing" "time" - libp2p "github.com/libp2p/go-libp2p" - host "github.com/libp2p/go-libp2p-host" - peerstore "github.com/libp2p/go-libp2p-peerstore" - protocol "github.com/libp2p/go-libp2p-protocol" + "github.com/libp2p/go-libp2p" + "github.com/libp2p/go-libp2p-core/host" + "github.com/libp2p/go-libp2p-core/peerstore" + "github.com/libp2p/go-libp2p-core/protocol" + multiaddr "github.com/multiformats/go-multiaddr" ) diff --git a/p2p/net/gostream/listener.go b/p2p/net/gostream/listener.go index e66c262a70..48e6cffb31 100644 --- a/p2p/net/gostream/listener.go +++ b/p2p/net/gostream/listener.go @@ -4,9 +4,9 @@ import ( "context" "net" - host "github.com/libp2p/go-libp2p-host" - pnet "github.com/libp2p/go-libp2p-net" - protocol "github.com/libp2p/go-libp2p-protocol" + "github.com/libp2p/go-libp2p-core/host" + "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-libp2p-core/protocol" ) // listener is an implementation of net.Listener which handles @@ -17,7 +17,7 @@ type listener struct { ctx context.Context tag protocol.ID cancel func() - streamCh chan pnet.Stream + streamCh chan network.Stream } // Accept returns the next a connection to this listener. @@ -56,10 +56,10 @@ func Listen(h host.Host, tag protocol.ID) (net.Listener, error) { ctx: ctx, cancel: cancel, tag: tag, - streamCh: make(chan pnet.Stream), + streamCh: make(chan network.Stream), } - h.SetStreamHandler(tag, func(s pnet.Stream) { + h.SetStreamHandler(tag, func(s network.Stream) { select { case l.streamCh <- s: case <-ctx.Done():