Commit 14aac9bb authored by Jeromy Johnson's avatar Jeromy Johnson Committed by GitHub
Browse files

Merge pull request #84 from libp2p/feat/update-multistream

update multistream deps and fix code to work with new changes
parents 5b9cd671 dd707e22
......@@ -5,16 +5,15 @@ import (
"fmt"
"io/ioutil"
"log"
"time"
pstore "github.com/ipfs/go-libp2p-peerstore"
host "github.com/ipfs/go-libp2p/p2p/host"
bhost "github.com/ipfs/go-libp2p/p2p/host/basic"
metrics "github.com/ipfs/go-libp2p/p2p/metrics"
net "github.com/ipfs/go-libp2p/p2p/net"
conn "github.com/ipfs/go-libp2p/p2p/net/conn"
swarm "github.com/ipfs/go-libp2p/p2p/net/swarm"
testutil "github.com/ipfs/go-libp2p/testutil"
host "github.com/libp2p/go-libp2p/p2p/host"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
metrics "github.com/libp2p/go-libp2p/p2p/metrics"
net "github.com/libp2p/go-libp2p/p2p/net"
conn "github.com/libp2p/go-libp2p/p2p/net/conn"
swarm "github.com/libp2p/go-libp2p/p2p/net/swarm"
testutil "github.com/libp2p/go-libp2p/testutil"
ipfsaddr "github.com/ipfs/go-ipfs/thirdparty/ipfsaddr"
ma "github.com/jbenet/go-multiaddr"
......
......@@ -12,10 +12,10 @@ import (
"github.com/cryptix/mdns"
"github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
"github.com/ipfs/go-libp2p/p2p/host"
logging "github.com/ipfs/go-log"
ma "github.com/jbenet/go-multiaddr"
manet "github.com/jbenet/go-multiaddr-net"
"github.com/libp2p/go-libp2p/p2p/host"
)
var log = logging.Logger("mdns")
......
......@@ -5,21 +5,21 @@ import (
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
metrics "github.com/ipfs/go-libp2p/p2p/metrics"
mstream "github.com/ipfs/go-libp2p/p2p/metrics/stream"
inet "github.com/ipfs/go-libp2p/p2p/net"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
identify "github.com/ipfs/go-libp2p/p2p/protocol/identify"
relay "github.com/ipfs/go-libp2p/p2p/protocol/relay"
logging "github.com/ipfs/go-log"
ma "github.com/jbenet/go-multiaddr"
goprocess "github.com/jbenet/goprocess"
metrics "github.com/libp2p/go-libp2p/p2p/metrics"
mstream "github.com/libp2p/go-libp2p/p2p/metrics/stream"
inet "github.com/libp2p/go-libp2p/p2p/net"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
identify "github.com/libp2p/go-libp2p/p2p/protocol/identify"
relay "github.com/libp2p/go-libp2p/p2p/protocol/relay"
context "golang.org/x/net/context"
msmux "github.com/whyrusleeping/go-multistream"
)
var log = logging.Logger("github.com/ipfs/go-libp2p/p2p/host/basic")
var log = logging.Logger("github.com/libp2p/go-libp2p/p2p/host/basic")
// Option is a type used to pass in options to the host.
type Option int
......@@ -114,7 +114,8 @@ func (h *BasicHost) newStreamHandler(s inet.Stream) {
logStream := mstream.WrapStream(s, protocol.ID(protoID), h.bwc)
go handle(logStream)
s.SetProtocol(protoID)
go handle(protoID, logStream)
}
// ID returns the (local) peer.ID associated with this Host
......@@ -147,8 +148,10 @@ func (h *BasicHost) IDService() *identify.IDService {
// host.Mux().SetHandler(proto, handler)
// (Threadsafe)
func (h *BasicHost) SetStreamHandler(pid protocol.ID, handler inet.StreamHandler) {
h.Mux().AddHandler(string(pid), func(rwc io.ReadWriteCloser) error {
handler(rwc.(inet.Stream))
h.Mux().AddHandler(string(pid), func(p string, rwc io.ReadWriteCloser) error {
is := rwc.(inet.Stream)
is.SetProtocol(p)
handler(is)
return nil
})
}
......
......@@ -5,9 +5,9 @@ import (
"io"
"testing"
inet "github.com/ipfs/go-libp2p/p2p/net"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
testutil "github.com/ipfs/go-libp2p/p2p/test/util"
inet "github.com/libp2p/go-libp2p/p2p/net"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"
context "golang.org/x/net/context"
)
......
......@@ -4,10 +4,10 @@ import (
"sync"
lgbl "github.com/ipfs/go-libp2p-loggables"
inat "github.com/ipfs/go-libp2p/p2p/nat"
inet "github.com/ipfs/go-libp2p/p2p/net"
ma "github.com/jbenet/go-multiaddr"
goprocess "github.com/jbenet/goprocess"
inat "github.com/libp2p/go-libp2p/p2p/nat"
inet "github.com/libp2p/go-libp2p/p2p/net"
context "golang.org/x/net/context"
)
......
......@@ -3,16 +3,16 @@ package host
import (
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
metrics "github.com/ipfs/go-libp2p/p2p/metrics"
inet "github.com/ipfs/go-libp2p/p2p/net"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
logging "github.com/ipfs/go-log"
ma "github.com/jbenet/go-multiaddr"
metrics "github.com/libp2p/go-libp2p/p2p/metrics"
inet "github.com/libp2p/go-libp2p/p2p/net"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
msmux "github.com/whyrusleeping/go-multistream"
context "golang.org/x/net/context"
)
var log = logging.Logger("github.com/ipfs/go-libp2p/p2p/host")
var log = logging.Logger("github.com/libp2p/go-libp2p/p2p/host")
// Host is an object participating in a p2p network, which
// implements protocols or provides services. It handles
......
......@@ -7,18 +7,18 @@ import (
lgbl "github.com/ipfs/go-libp2p-loggables"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
host "github.com/ipfs/go-libp2p/p2p/host"
metrics "github.com/ipfs/go-libp2p/p2p/metrics"
inet "github.com/ipfs/go-libp2p/p2p/net"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
logging "github.com/ipfs/go-log"
ma "github.com/jbenet/go-multiaddr"
host "github.com/libp2p/go-libp2p/p2p/host"
metrics "github.com/libp2p/go-libp2p/p2p/metrics"
inet "github.com/libp2p/go-libp2p/p2p/net"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
context "golang.org/x/net/context"
msmux "github.com/whyrusleeping/go-multistream"
)
var log = logging.Logger("github.com/ipfs/go-libp2p/p2p/host/routed")
var log = logging.Logger("github.com/libp2p/go-libp2p/p2p/host/routed")
// AddressTTL is the expiry time for our addresses.
// We expire them quickly.
......
......@@ -5,7 +5,7 @@ import (
"sync"
peer "github.com/ipfs/go-libp2p-peer"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
)
type Stats struct {
......
......@@ -2,7 +2,7 @@ package meterconn
import (
transport "github.com/ipfs/go-libp2p-transport"
metrics "github.com/ipfs/go-libp2p/p2p/metrics"
metrics "github.com/libp2p/go-libp2p/p2p/metrics"
)
type MeteredConn struct {
......
......@@ -2,7 +2,7 @@ package metrics
import (
peer "github.com/ipfs/go-libp2p-peer"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
)
type StreamMeterCallback func(int64, protocol.ID, peer.ID)
......
......@@ -2,9 +2,9 @@ package meterstream
import (
peer "github.com/ipfs/go-libp2p-peer"
metrics "github.com/ipfs/go-libp2p/p2p/metrics"
inet "github.com/ipfs/go-libp2p/p2p/net"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
metrics "github.com/libp2p/go-libp2p/p2p/metrics"
inet "github.com/libp2p/go-libp2p/p2p/net"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
)
type meteredStream struct {
......
......@@ -7,8 +7,8 @@ import (
randbo "github.com/dustin/randbo"
peer "github.com/ipfs/go-libp2p-peer"
inet "github.com/ipfs/go-libp2p/p2p/net"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
inet "github.com/libp2p/go-libp2p/p2p/net"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
)
type FakeStream struct {
......
......@@ -8,8 +8,8 @@ import (
"testing"
"time"
travis "github.com/ipfs/go-libp2p/testutil/ci/travis"
msgio "github.com/jbenet/go-msgio"
travis "github.com/libp2p/go-libp2p/testutil/ci/travis"
context "golang.org/x/net/context"
)
......
......@@ -10,9 +10,9 @@ import (
lgbl "github.com/ipfs/go-libp2p-loggables"
peer "github.com/ipfs/go-libp2p-peer"
transport "github.com/ipfs/go-libp2p-transport"
addrutil "github.com/ipfs/go-libp2p/p2p/net/swarm/addr"
ma "github.com/jbenet/go-multiaddr"
manet "github.com/jbenet/go-multiaddr-net"
addrutil "github.com/libp2p/go-libp2p/p2p/net/swarm/addr"
msmux "github.com/whyrusleeping/go-multistream"
context "golang.org/x/net/context"
)
......
......@@ -14,7 +14,7 @@ import (
ic "github.com/ipfs/go-libp2p-crypto"
peer "github.com/ipfs/go-libp2p-peer"
transport "github.com/ipfs/go-libp2p-transport"
tu "github.com/ipfs/go-libp2p/testutil"
tu "github.com/libp2p/go-libp2p/testutil"
ma "github.com/jbenet/go-multiaddr"
msmux "github.com/whyrusleeping/go-multistream"
......@@ -23,7 +23,7 @@ import (
)
func goroFilter(r *grc.Goroutine) bool {
return strings.Contains(r.Function, "go-log.")
return strings.Contains(r.Function, "go-log.") || strings.Contains(r.Stack[0], "testing.(*T).Run")
}
func echoListen(ctx context.Context, listener Listener) {
......
......@@ -8,8 +8,8 @@ import (
ic "github.com/ipfs/go-libp2p-crypto"
peer "github.com/ipfs/go-libp2p-peer"
transport "github.com/ipfs/go-libp2p-transport"
filter "github.com/ipfs/go-libp2p/p2p/net/filter"
ma "github.com/jbenet/go-multiaddr"
filter "github.com/libp2p/go-libp2p/p2p/net/filter"
)
type PeerConn interface {
......
......@@ -10,11 +10,11 @@ import (
ic "github.com/ipfs/go-libp2p-crypto"
peer "github.com/ipfs/go-libp2p-peer"
transport "github.com/ipfs/go-libp2p-transport"
filter "github.com/ipfs/go-libp2p/p2p/net/filter"
ma "github.com/jbenet/go-multiaddr"
tec "github.com/jbenet/go-temp-err-catcher"
"github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context"
filter "github.com/libp2p/go-libp2p/p2p/net/filter"
msmux "github.com/whyrusleeping/go-multistream"
context "golang.org/x/net/context"
)
......
......@@ -8,7 +8,7 @@ import (
"time"
ic "github.com/ipfs/go-libp2p-crypto"
travis "github.com/ipfs/go-libp2p/testutil/ci/travis"
travis "github.com/libp2p/go-libp2p/testutil/ci/travis"
context "golang.org/x/net/context"
)
......
......@@ -5,9 +5,9 @@ import (
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
conn "github.com/ipfs/go-libp2p/p2p/net/conn"
ma "github.com/jbenet/go-multiaddr"
"github.com/jbenet/goprocess"
conn "github.com/libp2p/go-libp2p/p2p/net/conn"
context "golang.org/x/net/context"
)
......@@ -26,6 +26,9 @@ type Stream interface {
io.Writer
io.Closer
Protocol() string
SetProtocol(string)
// Conn returns the connection this stream is part of.
Conn() Conn
}
......
......@@ -10,8 +10,8 @@ import (
"io"
"time"
host "github.com/ipfs/go-libp2p/p2p/host"
inet "github.com/ipfs/go-libp2p/p2p/net"
host "github.com/libp2p/go-libp2p/p2p/host"
inet "github.com/libp2p/go-libp2p/p2p/net"
ic "github.com/ipfs/go-libp2p-crypto"
peer "github.com/ipfs/go-libp2p-peer"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment