Skip to content

Commit

Permalink
migrate to consolidated types. (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk authored May 26, 2019
1 parent 8eef3f7 commit 3255249
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 8 additions & 6 deletions p2p/transport/websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"net/http"
"net/url"

ws "github.com/gorilla/websocket"
peer "github.com/libp2p/go-libp2p-peer"
tpt "github.com/libp2p/go-libp2p-transport"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/transport"

tptu "github.com/libp2p/go-libp2p-transport-upgrader"

ws "github.com/gorilla/websocket"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
mafmt "github.com/whyrusleeping/mafmt"
Expand Down Expand Up @@ -61,7 +63,7 @@ func New(u *tptu.Upgrader) *WebsocketTransport {
return &WebsocketTransport{u}
}

var _ tpt.Transport = (*WebsocketTransport)(nil)
var _ transport.Transport = (*WebsocketTransport)(nil)

func (t *WebsocketTransport) CanDial(a ma.Multiaddr) bool {
return WsFmt.Matches(a)
Expand Down Expand Up @@ -94,7 +96,7 @@ func (t *WebsocketTransport) maDial(ctx context.Context, raddr ma.Multiaddr) (ma
return mnc, nil
}

func (t *WebsocketTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (tpt.Conn, error) {
func (t *WebsocketTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error) {
macon, err := t.maDial(ctx, raddr)
if err != nil {
return nil, err
Expand Down Expand Up @@ -130,7 +132,7 @@ func (t *WebsocketTransport) maListen(a ma.Multiaddr) (manet.Listener, error) {
return malist, nil
}

func (t *WebsocketTransport) Listen(a ma.Multiaddr) (tpt.Listener, error) {
func (t *WebsocketTransport) Listen(a ma.Multiaddr) (transport.Listener, error) {
malist, err := t.maListen(a)
if err != nil {
return nil, err
Expand Down
7 changes: 4 additions & 3 deletions p2p/transport/websocket/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import (
"testing"
"testing/iotest"

insecure "github.com/libp2p/go-conn-security/insecure"
"github.com/libp2p/go-libp2p-core/sec/insecure"

mplex "github.com/libp2p/go-libp2p-mplex"
ttransport "github.com/libp2p/go-libp2p-testing/suites/transport"
tptu "github.com/libp2p/go-libp2p-transport-upgrader"
utils "github.com/libp2p/go-libp2p-transport/test"
ma "github.com/multiformats/go-multiaddr"
)

Expand Down Expand Up @@ -50,7 +51,7 @@ func TestWebsocketTransport(t *testing.T) {
})

zero := "/ip4/127.0.0.1/tcp/0/ws"
utils.SubtestTransport(t, ta, tb, zero, "peerA")
ttransport.SubtestTransport(t, ta, tb, zero, "peerA")
}

func TestWebsocketListen(t *testing.T) {
Expand Down

0 comments on commit 3255249

Please sign in to comment.