Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
14aac9bb
Commit
14aac9bb
authored
Aug 10, 2016
by
Jeromy Johnson
Committed by
GitHub
Aug 10, 2016
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
Changes
56
Show whitespace changes
Inline
Side-by-side
p2p/net/swarm/swarm_net_test.go
View file @
14aac9bb
...
@@ -5,8 +5,8 @@ import (
...
@@ -5,8 +5,8 @@ import (
"testing"
"testing"
"time"
"time"
inet
"github.com/
ipfs
/go-libp2p/p2p/net"
inet
"github.com/
libp2p
/go-libp2p/p2p/net"
testutil
"github.com/
ipfs
/go-libp2p/p2p/test/util"
testutil
"github.com/
libp2p
/go-libp2p/p2p/test/util"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
)
)
...
...
p2p/net/swarm/swarm_notif_test.go
View file @
14aac9bb
...
@@ -5,11 +5,17 @@ import (
...
@@ -5,11 +5,17 @@ import (
"time"
"time"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
inet
"github.com/ipfs/go-libp2p/p2p/net"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
inet
"github.com/libp2p/go-libp2p/p2p/net"
context
"golang.org/x/net/context"
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
)
{
func
TestNotifications
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
swarms
:=
makeSwarms
(
ctx
,
t
,
5
)
swarms
:=
makeSwarms
(
ctx
,
t
,
5
)
...
@@ -98,7 +104,7 @@ func TestNotifications(t *testing.T) {
...
@@ -98,7 +104,7 @@ func TestNotifications(t *testing.T) {
case
<-
time
.
After
(
timeout
)
:
case
<-
time
.
After
(
timeout
)
:
t
.
Fatal
(
"timeout"
)
t
.
Fatal
(
"timeout"
)
}
}
if
s
!=
s2
{
if
!
streamsSame
(
s
,
s2
)
{
t
.
Fatal
(
"got incorrect stream"
,
s
.
Conn
(),
s2
.
Conn
())
t
.
Fatal
(
"got incorrect stream"
,
s
.
Conn
(),
s2
.
Conn
())
}
}
...
@@ -108,7 +114,7 @@ func TestNotifications(t *testing.T) {
...
@@ -108,7 +114,7 @@ func TestNotifications(t *testing.T) {
case
<-
time
.
After
(
timeout
)
:
case
<-
time
.
After
(
timeout
)
:
t
.
Fatal
(
"timeout"
)
t
.
Fatal
(
"timeout"
)
}
}
if
s
!=
s2
{
if
!
streamsSame
(
s
,
s2
)
{
t
.
Fatal
(
"got incorrect stream"
,
s
.
Conn
(),
s2
.
Conn
())
t
.
Fatal
(
"got incorrect stream"
,
s
.
Conn
(),
s2
.
Conn
())
}
}
}
}
...
...
p2p/net/swarm/swarm_stream.go
View file @
14aac9bb
package
swarm
package
swarm
import
(
import
(
inet
"github.com/
ipfs
/go-libp2p/p2p/net"
inet
"github.com/
libp2p
/go-libp2p/p2p/net"
ps
"github.com/jbenet/go-peerstream"
ps
"github.com/jbenet/go-peerstream"
)
)
// a Stream is a wrapper around a ps.Stream that exposes a way to get
// 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)
// 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
// Stream returns the underlying peerstream.Stream
func
(
s
*
Stream
)
Stream
()
*
ps
.
Stream
{
func
(
s
*
Stream
)
Stream
()
*
ps
.
Stream
{
return
(
*
p
s
.
S
tream
)(
s
)
return
s
.
s
tream
}
}
// Conn returns the Conn associated with this Stream, as an inet.Conn
// Conn returns the Conn associated with this Stream, as an inet.Conn
...
@@ -22,27 +25,37 @@ func (s *Stream) Conn() inet.Conn {
...
@@ -22,27 +25,37 @@ func (s *Stream) Conn() inet.Conn {
// SwarmConn returns the Conn associated with this Stream, as a *Conn
// SwarmConn returns the Conn associated with this Stream, as a *Conn
func
(
s
*
Stream
)
SwarmConn
()
*
Conn
{
func
(
s
*
Stream
)
SwarmConn
()
*
Conn
{
return
(
*
Conn
)(
s
.
S
tream
()
.
Conn
())
return
(
*
Conn
)(
s
.
s
tream
.
Conn
())
}
}
// Read reads bytes from a stream.
// Read reads bytes from a stream.
func
(
s
*
Stream
)
Read
(
p
[]
byte
)
(
n
int
,
err
error
)
{
func
(
s
*
Stream
)
Read
(
p
[]
byte
)
(
n
int
,
err
error
)
{
return
s
.
S
tream
()
.
Read
(
p
)
return
s
.
s
tream
.
Read
(
p
)
}
}
// Write writes bytes to a stream, flushing for each call.
// Write writes bytes to a stream, flushing for each call.
func
(
s
*
Stream
)
Write
(
p
[]
byte
)
(
n
int
,
err
error
)
{
func
(
s
*
Stream
)
Write
(
p
[]
byte
)
(
n
int
,
err
error
)
{
return
s
.
S
tream
()
.
Write
(
p
)
return
s
.
s
tream
.
Write
(
p
)
}
}
// Close closes the stream, indicating this side is finished
// Close closes the stream, indicating this side is finished
// with the stream.
// with the stream.
func
(
s
*
Stream
)
Close
()
error
{
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
{
func
wrapStream
(
pss
*
ps
.
Stream
)
*
Stream
{
return
(
*
Stream
)(
pss
)
return
&
Stream
{
stream
:
pss
,
}
}
}
func
wrapStreams
(
st
[]
*
ps
.
Stream
)
[]
*
Stream
{
func
wrapStreams
(
st
[]
*
ps
.
Stream
)
[]
*
Stream
{
...
...
p2p/net/swarm/swarm_test.go
View file @
14aac9bb
...
@@ -9,9 +9,9 @@ import (
...
@@ -9,9 +9,9 @@ import (
"testing"
"testing"
"time"
"time"
metrics
"github.com/
ipfs
/go-libp2p/p2p/metrics"
metrics
"github.com/
libp2p
/go-libp2p/p2p/metrics"
inet
"github.com/
ipfs
/go-libp2p/p2p/net"
inet
"github.com/
libp2p
/go-libp2p/p2p/net"
testutil
"github.com/
ipfs
/go-libp2p/testutil"
testutil
"github.com/
libp2p
/go-libp2p/testutil"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
pstore
"github.com/ipfs/go-libp2p-peerstore"
pstore
"github.com/ipfs/go-libp2p-peerstore"
...
...
p2p/protocol/identify/id.go
View file @
14aac9bb
...
@@ -7,11 +7,11 @@ import (
...
@@ -7,11 +7,11 @@ import (
semver
"github.com/coreos/go-semver/semver"
semver
"github.com/coreos/go-semver/semver"
ggio
"github.com/gogo/protobuf/io"
ggio
"github.com/gogo/protobuf/io"
pstore
"github.com/ipfs/go-libp2p-peerstore"
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"
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"
msmux
"github.com/whyrusleeping/go-multistream"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
...
...
p2p/protocol/identify/id_test.go
View file @
14aac9bb
...
@@ -5,9 +5,9 @@ import (
...
@@ -5,9 +5,9 @@ import (
"time"
"time"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
host
"github.com/
ipfs
/go-libp2p/p2p/host"
host
"github.com/
libp2p
/go-libp2p/p2p/host"
identify
"github.com/
ipfs
/go-libp2p/p2p/protocol/identify"
identify
"github.com/
libp2p
/go-libp2p/p2p/protocol/identify"
testutil
"github.com/
ipfs
/go-libp2p/p2p/test/util"
testutil
"github.com/
libp2p
/go-libp2p/p2p/test/util"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
...
...
p2p/protocol/ping/ping.go
View file @
14aac9bb
...
@@ -8,9 +8,9 @@ import (
...
@@ -8,9 +8,9 @@ import (
u
"github.com/ipfs/go-ipfs-util"
u
"github.com/ipfs/go-ipfs-util"
peer
"github.com/ipfs/go-libp2p-peer"
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"
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"
context
"golang.org/x/net/context"
)
)
...
...
p2p/protocol/ping/ping_test.go
View file @
14aac9bb
...
@@ -4,7 +4,7 @@ import (
...
@@ -4,7 +4,7 @@ import (
"testing"
"testing"
"time"
"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"
peer
"github.com/ipfs/go-libp2p-peer"
pstore
"github.com/ipfs/go-libp2p-peerstore"
pstore
"github.com/ipfs/go-libp2p-peerstore"
...
...
p2p/protocol/relay/relay.go
View file @
14aac9bb
...
@@ -6,15 +6,15 @@ import (
...
@@ -6,15 +6,15 @@ import (
"time"
"time"
peer
"github.com/ipfs/go-libp2p-peer"
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"
logging
"github.com/ipfs/go-log"
mh
"github.com/jbenet/go-multihash"
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"
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.
// ID is the protocol.ID of the Relay Service.
const
ID
protocol
.
ID
=
"/ipfs/relay/line/0.1.0"
const
ID
protocol
.
ID
=
"/ipfs/relay/line/0.1.0"
...
...
p2p/protocol/relay/relay_test.go
View file @
14aac9bb
...
@@ -4,11 +4,11 @@ import (
...
@@ -4,11 +4,11 @@ import (
"io"
"io"
"testing"
"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"
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"
msmux
"github.com/whyrusleeping/go-multistream"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
)
)
...
...
p2p/test/backpressure/backpressure_test.go
View file @
14aac9bb
...
@@ -8,11 +8,11 @@ import (
...
@@ -8,11 +8,11 @@ import (
u
"github.com/ipfs/go-ipfs-util"
u
"github.com/ipfs/go-ipfs-util"
peer
"github.com/ipfs/go-libp2p-peer"
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"
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"
context
"golang.org/x/net/context"
)
)
...
...
p2p/test/reconnects/reconnect_test.go
View file @
14aac9bb
...
@@ -8,13 +8,13 @@ import (
...
@@ -8,13 +8,13 @@ import (
"time"
"time"
u
"github.com/ipfs/go-ipfs-util"
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"
logging
"github.com/ipfs/go-log"
ps
"github.com/jbenet/go-peerstream"
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"
context
"golang.org/x/net/context"
)
)
...
...
p2p/test/util/key.go
View file @
14aac9bb
...
@@ -8,8 +8,8 @@ import (
...
@@ -8,8 +8,8 @@ import (
u
"github.com/ipfs/go-ipfs-util"
u
"github.com/ipfs/go-ipfs-util"
ic
"github.com/ipfs/go-libp2p-crypto"
ic
"github.com/ipfs/go-libp2p-crypto"
peer
"github.com/ipfs/go-libp2p-peer"
peer
"github.com/ipfs/go-libp2p-peer"
testutil
"github.com/ipfs/go-libp2p/testutil"
logging
"github.com/ipfs/go-log"
logging
"github.com/ipfs/go-log"
testutil
"github.com/libp2p/go-libp2p/testutil"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
)
)
...
...
p2p/test/util/util.go
View file @
14aac9bb
...
@@ -4,11 +4,11 @@ import (
...
@@ -4,11 +4,11 @@ import (
"testing"
"testing"
pstore
"github.com/ipfs/go-libp2p-peerstore"
pstore
"github.com/ipfs/go-libp2p-peerstore"
bhost
"github.com/
ipfs
/go-libp2p/p2p/host/basic"
bhost
"github.com/
libp2p
/go-libp2p/p2p/host/basic"
metrics
"github.com/
ipfs
/go-libp2p/p2p/metrics"
metrics
"github.com/
libp2p
/go-libp2p/p2p/metrics"
inet
"github.com/
ipfs
/go-libp2p/p2p/net"
inet
"github.com/
libp2p
/go-libp2p/p2p/net"
swarm
"github.com/
ipfs
/go-libp2p/p2p/net/swarm"
swarm
"github.com/
libp2p
/go-libp2p/p2p/net/swarm"
tu
"github.com/
ipfs
/go-libp2p/testutil"
tu
"github.com/
libp2p
/go-libp2p/testutil"
ma
"github.com/jbenet/go-multiaddr"
ma
"github.com/jbenet/go-multiaddr"
context
"golang.org/x/net/context"
context
"golang.org/x/net/context"
...
...
package.json
View file @
14aac9bb
...
@@ -34,9 +34,9 @@
...
@@ -34,9 +34,9 @@
"version"
:
"1.0.0"
"version"
:
"1.0.0"
},
},
{
{
"hash"
:
"Qm
f91yhgRLo2dhhbc5zZ7TxjMaR1oxaWaoc9zRZdi1kU4a
"
,
"hash"
:
"Qm
XAWgboitGTKjCqHjVNKMAU13hV5LjYMui8n3UAGPBDLp
"
,
"name"
:
"go-multistream"
,
"name"
:
"go-multistream"
,
"version"
:
"0.
0
.0"
"version"
:
"0.
2
.0"
},
},
{
{
"hash"
:
"QmNLvkCDV6ZjUJsEwGNporYBuZdhWT6q7TBVYQwwRv12HT"
,
"hash"
:
"QmNLvkCDV6ZjUJsEwGNporYBuZdhWT6q7TBVYQwwRv12HT"
,
...
@@ -171,9 +171,9 @@
...
@@ -171,9 +171,9 @@
},
},
{
{
"author"
:
"whyrusleeping"
,
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
VcmcQE9eX4HQ8QwhVXpoHt3ennG7d299NDYFq9D1Uqa1
"
,
"hash"
:
"Qm
cK5em8AHkQf72b4JPyDdyuKkCc7xADTEN7w26CJh4uQN
"
,
"name"
:
"go-smux-multistream"
,
"name"
:
"go-smux-multistream"
,
"version"
:
"1.
0
.0"
"version"
:
"1.
2
.0"
},
},
{
{
"author"
:
"whyrusleeping"
,
"author"
:
"whyrusleeping"
,
...
...
testutil/ci/ci.go
View file @
14aac9bb
...
@@ -6,8 +6,8 @@ package ci
...
@@ -6,8 +6,8 @@ package ci
import
(
import
(
"os"
"os"
jenkins
"github.com/
ipfs
/go-libp2p/testutil/ci/jenkins"
jenkins
"github.com/
libp2p
/go-libp2p/testutil/ci/jenkins"
travis
"github.com/
ipfs
/go-libp2p/testutil/ci/travis"
travis
"github.com/
libp2p
/go-libp2p/testutil/ci/travis"
)
)
// EnvVar is a type to use travis-only env var names with
// EnvVar is a type to use travis-only env var names with
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment