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,8 +5,8 @@ import (
"testing"
"time"
inet "github.com/ipfs/go-libp2p/p2p/net"
testutil "github.com/ipfs/go-libp2p/p2p/test/util"
inet "github.com/libp2p/go-libp2p/p2p/net"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"
context "golang.org/x/net/context"
)
......
......@@ -5,11 +5,17 @@ import (
"time"
peer "github.com/ipfs/go-libp2p-peer"
inet "github.com/ipfs/go-libp2p/p2p/net"
ma "github.com/jbenet/go-multiaddr"
inet "github.com/libp2p/go-libp2p/p2p/net"
context "golang.org/x/net/context"
)
func streamsSame(a, b inet.Stream) bool {
sa := a.(*Stream)
sb := b.(*Stream)
return sa.Stream() == sb.Stream()
}
func TestNotifications(t *testing.T) {
ctx := context.Background()
swarms := makeSwarms(ctx, t, 5)
......@@ -98,7 +104,7 @@ func TestNotifications(t *testing.T) {
case <-time.After(timeout):
t.Fatal("timeout")
}
if s != s2 {
if !streamsSame(s, s2) {
t.Fatal("got incorrect stream", s.Conn(), s2.Conn())
}
......@@ -108,7 +114,7 @@ func TestNotifications(t *testing.T) {
case <-time.After(timeout):
t.Fatal("timeout")
}
if s != s2 {
if !streamsSame(s, s2) {
t.Fatal("got incorrect stream", s.Conn(), s2.Conn())
}
}
......
package swarm
import (
inet "github.com/ipfs/go-libp2p/p2p/net"
inet "github.com/libp2p/go-libp2p/p2p/net"
ps "github.com/jbenet/go-peerstream"
)
// a Stream is a wrapper around a ps.Stream that exposes a way to get
// our Conn and Swarm (instead of just the ps.Conn and ps.Swarm)
type Stream ps.Stream
type Stream struct {
stream *ps.Stream
protocol string
}
// Stream returns the underlying peerstream.Stream
func (s *Stream) Stream() *ps.Stream {
return (*ps.Stream)(s)
return s.stream
}
// Conn returns the Conn associated with this Stream, as an inet.Conn
......@@ -22,27 +25,37 @@ func (s *Stream) Conn() inet.Conn {
// SwarmConn returns the Conn associated with this Stream, as a *Conn
func (s *Stream) SwarmConn() *Conn {
return (*Conn)(s.Stream().Conn())
return (*Conn)(s.stream.Conn())
}
// Read reads bytes from a stream.
func (s *Stream) Read(p []byte) (n int, err error) {
return s.Stream().Read(p)
return s.stream.Read(p)
}
// Write writes bytes to a stream, flushing for each call.
func (s *Stream) Write(p []byte) (n int, err error) {
return s.Stream().Write(p)
return s.stream.Write(p)
}
// Close closes the stream, indicating this side is finished
// with the stream.
func (s *Stream) Close() error {
return s.Stream().Close()
return s.stream.Close()
}
func (s *Stream) Protocol() string {
return s.protocol
}
func (s *Stream) SetProtocol(p string) {
s.protocol = p
}
func wrapStream(pss *ps.Stream) *Stream {
return (*Stream)(pss)
return &Stream{
stream: pss,
}
}
func wrapStreams(st []*ps.Stream) []*Stream {
......
......@@ -9,9 +9,9 @@ import (
"testing"
"time"
metrics "github.com/ipfs/go-libp2p/p2p/metrics"
inet "github.com/ipfs/go-libp2p/p2p/net"
testutil "github.com/ipfs/go-libp2p/testutil"
metrics "github.com/libp2p/go-libp2p/p2p/metrics"
inet "github.com/libp2p/go-libp2p/p2p/net"
testutil "github.com/libp2p/go-libp2p/testutil"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
......
......@@ -7,11 +7,11 @@ import (
semver "github.com/coreos/go-semver/semver"
ggio "github.com/gogo/protobuf/io"
pstore "github.com/ipfs/go-libp2p-peerstore"
host "github.com/ipfs/go-libp2p/p2p/host"
mstream "github.com/ipfs/go-libp2p/p2p/metrics/stream"
inet "github.com/ipfs/go-libp2p/p2p/net"
pb "github.com/ipfs/go-libp2p/p2p/protocol/identify/pb"
ma "github.com/jbenet/go-multiaddr"
host "github.com/libp2p/go-libp2p/p2p/host"
mstream "github.com/libp2p/go-libp2p/p2p/metrics/stream"
inet "github.com/libp2p/go-libp2p/p2p/net"
pb "github.com/libp2p/go-libp2p/p2p/protocol/identify/pb"
msmux "github.com/whyrusleeping/go-multistream"
context "golang.org/x/net/context"
......
......@@ -5,9 +5,9 @@ import (
"time"
peer "github.com/ipfs/go-libp2p-peer"
host "github.com/ipfs/go-libp2p/p2p/host"
identify "github.com/ipfs/go-libp2p/p2p/protocol/identify"
testutil "github.com/ipfs/go-libp2p/p2p/test/util"
host "github.com/libp2p/go-libp2p/p2p/host"
identify "github.com/libp2p/go-libp2p/p2p/protocol/identify"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"
ma "github.com/jbenet/go-multiaddr"
context "golang.org/x/net/context"
......
......@@ -8,9 +8,9 @@ import (
u "github.com/ipfs/go-ipfs-util"
peer "github.com/ipfs/go-libp2p-peer"
host "github.com/ipfs/go-libp2p/p2p/host"
inet "github.com/ipfs/go-libp2p/p2p/net"
logging "github.com/ipfs/go-log"
host "github.com/libp2p/go-libp2p/p2p/host"
inet "github.com/libp2p/go-libp2p/p2p/net"
context "golang.org/x/net/context"
)
......
......@@ -4,7 +4,7 @@ import (
"testing"
"time"
netutil "github.com/ipfs/go-libp2p/p2p/test/util"
netutil "github.com/libp2p/go-libp2p/p2p/test/util"
peer "github.com/ipfs/go-libp2p-peer"
pstore "github.com/ipfs/go-libp2p-peerstore"
......
......@@ -6,15 +6,15 @@ import (
"time"
peer "github.com/ipfs/go-libp2p-peer"
host "github.com/ipfs/go-libp2p/p2p/host"
inet "github.com/ipfs/go-libp2p/p2p/net"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
logging "github.com/ipfs/go-log"
mh "github.com/jbenet/go-multihash"
host "github.com/libp2p/go-libp2p/p2p/host"
inet "github.com/libp2p/go-libp2p/p2p/net"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
context "golang.org/x/net/context"
)
var log = logging.Logger("github.com/ipfs/go-libp2p/p2p/protocol/relay")
var log = logging.Logger("github.com/libp2p/go-libp2p/p2p/protocol/relay")
// ID is the protocol.ID of the Relay Service.
const ID protocol.ID = "/ipfs/relay/line/0.1.0"
......
......@@ -4,11 +4,11 @@ import (
"io"
"testing"
inet "github.com/ipfs/go-libp2p/p2p/net"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
relay "github.com/ipfs/go-libp2p/p2p/protocol/relay"
testutil "github.com/ipfs/go-libp2p/p2p/test/util"
logging "github.com/ipfs/go-log"
inet "github.com/libp2p/go-libp2p/p2p/net"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
relay "github.com/libp2p/go-libp2p/p2p/protocol/relay"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"
msmux "github.com/whyrusleeping/go-multistream"
context "golang.org/x/net/context"
)
......
......@@ -8,11 +8,11 @@ import (
u "github.com/ipfs/go-ipfs-util"
peer "github.com/ipfs/go-libp2p-peer"
host "github.com/ipfs/go-libp2p/p2p/host"
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"
logging "github.com/ipfs/go-log"
host "github.com/libp2p/go-libp2p/p2p/host"
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"
)
......
......@@ -8,13 +8,13 @@ import (
"time"
u "github.com/ipfs/go-ipfs-util"
host "github.com/ipfs/go-libp2p/p2p/host"
inet "github.com/ipfs/go-libp2p/p2p/net"
swarm "github.com/ipfs/go-libp2p/p2p/net/swarm"
protocol "github.com/ipfs/go-libp2p/p2p/protocol"
testutil "github.com/ipfs/go-libp2p/p2p/test/util"
logging "github.com/ipfs/go-log"
ps "github.com/jbenet/go-peerstream"
host "github.com/libp2p/go-libp2p/p2p/host"
inet "github.com/libp2p/go-libp2p/p2p/net"
swarm "github.com/libp2p/go-libp2p/p2p/net/swarm"
protocol "github.com/libp2p/go-libp2p/p2p/protocol"
testutil "github.com/libp2p/go-libp2p/p2p/test/util"
context "golang.org/x/net/context"
)
......
......@@ -8,8 +8,8 @@ import (
u "github.com/ipfs/go-ipfs-util"
ic "github.com/ipfs/go-libp2p-crypto"
peer "github.com/ipfs/go-libp2p-peer"
testutil "github.com/ipfs/go-libp2p/testutil"
logging "github.com/ipfs/go-log"
testutil "github.com/libp2p/go-libp2p/testutil"
ma "github.com/jbenet/go-multiaddr"
)
......
......@@ -4,11 +4,11 @@ import (
"testing"
pstore "github.com/ipfs/go-libp2p-peerstore"
bhost "github.com/ipfs/go-libp2p/p2p/host/basic"
metrics "github.com/ipfs/go-libp2p/p2p/metrics"
inet "github.com/ipfs/go-libp2p/p2p/net"
swarm "github.com/ipfs/go-libp2p/p2p/net/swarm"
tu "github.com/ipfs/go-libp2p/testutil"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
metrics "github.com/libp2p/go-libp2p/p2p/metrics"
inet "github.com/libp2p/go-libp2p/p2p/net"
swarm "github.com/libp2p/go-libp2p/p2p/net/swarm"
tu "github.com/libp2p/go-libp2p/testutil"
ma "github.com/jbenet/go-multiaddr"
context "golang.org/x/net/context"
......
......@@ -34,9 +34,9 @@
"version": "1.0.0"
},
{
"hash": "Qmf91yhgRLo2dhhbc5zZ7TxjMaR1oxaWaoc9zRZdi1kU4a",
"hash": "QmXAWgboitGTKjCqHjVNKMAU13hV5LjYMui8n3UAGPBDLp",
"name": "go-multistream",
"version": "0.0.0"
"version": "0.2.0"
},
{
"hash": "QmNLvkCDV6ZjUJsEwGNporYBuZdhWT6q7TBVYQwwRv12HT",
......@@ -171,9 +171,9 @@
},
{
"author": "whyrusleeping",
"hash": "QmVcmcQE9eX4HQ8QwhVXpoHt3ennG7d299NDYFq9D1Uqa1",
"hash": "QmcK5em8AHkQf72b4JPyDdyuKkCc7xADTEN7w26CJh4uQN",
"name": "go-smux-multistream",
"version": "1.0.0"
"version": "1.2.0"
},
{
"author": "whyrusleeping",
......
......@@ -6,8 +6,8 @@ package ci
import (
"os"
jenkins "github.com/ipfs/go-libp2p/testutil/ci/jenkins"
travis "github.com/ipfs/go-libp2p/testutil/ci/travis"
jenkins "github.com/libp2p/go-libp2p/testutil/ci/jenkins"
travis "github.com/libp2p/go-libp2p/testutil/ci/travis"
)
// EnvVar is a type to use travis-only env var names with
......
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