Skip to content

Commit

Permalink
Merge pull request #26 from raulk/migrate-types
Browse files Browse the repository at this point in the history
migrate to consolidated types.
  • Loading branch information
hsanjuan committed May 27, 2019
2 parents 2e9c129 + 9e002de commit 6fc01ef
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion p2p/net/gostream/addr.go
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
15 changes: 8 additions & 7 deletions p2p/net/gostream/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}

Expand All @@ -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
}

Expand Down
9 changes: 5 additions & 4 deletions p2p/net/gostream/gostream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
12 changes: 6 additions & 6 deletions p2p/net/gostream/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 6fc01ef

Please sign in to comment.