Skip to content

Commit

Permalink
move multiaddr protocol definitions to go-multiaddr
Browse files Browse the repository at this point in the history
That way, users don't need to import the transport just to parse a websocket
multiaddr.
  • Loading branch information
Stebalien committed Sep 19, 2019
1 parent 3255249 commit 7b972a0
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions p2p/transport/websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package websocket

import (
"context"
"fmt"
"net"
"net/http"
"net/url"
Expand All @@ -20,11 +19,9 @@ import (
)

// WsProtocol is the multiaddr protocol definition for this transport.
var WsProtocol = ma.Protocol{
Code: 477,
Name: "ws",
VCode: ma.CodeToVarint(477),
}
//
// Deprecated: use `ma.ProtocolWithCode(ma.P_WS)
var WsProtocol = ma.ProtocolWithCode(ma.P_WS)

// WsFmt is multiaddr formatter for WsProtocol
var WsFmt = mafmt.And(mafmt.TCP, mafmt.Base(WsProtocol.Code))
Expand All @@ -46,11 +43,6 @@ var upgrader = ws.Upgrader{
}

func init() {
err := ma.AddProtocol(WsProtocol)
if err != nil {
panic(fmt.Errorf("error registering websocket protocol: %s", err))
}

manet.RegisterNetCodec(WsCodec)
}

Expand Down

0 comments on commit 7b972a0

Please sign in to comment.