Commit a474b7b4 authored by Jeromy Johnson's avatar Jeromy Johnson Committed by GitHub

Merge pull request #35 from libp2p/feat/update-stream-muxer

Update stream muxer.
parents e3054377 768ec4e4
1.7.7: QmQUmDr1DMDDy6KMSsJuyV9nVD7dJZ9iWxXESQWPvte2NP 2.0.0: QmZr3z6ZdvYZgRquj6VJZL7kd5aSfbxUD2FTwFPdRsQMYo
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
"gxDependencies": [ "gxDependencies": [
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmahYsGWry85Y7WUe2SX5G4JkH2zifEQAUtJVLZ24aC9DF", "hash": "QmNa31VPzC561NWwRsJLE7nGYZYuuD2QfpK2b1q9BK54J1",
"name": "go-libp2p-net", "name": "go-libp2p-net",
"version": "1.6.12" "version": "2.0.0"
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
...@@ -39,21 +39,21 @@ ...@@ -39,21 +39,21 @@
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmWUNsat6Jb19nC5CiJCDXepTkxjdxi3eZqeoB6mrmmaGu", "hash": "QmQFhPsJCp82az4SXbziP9QcVSqggEELnV9wGZqMR1EfMB",
"name": "go-smux-spdystream", "name": "go-smux-spdystream",
"version": "1.2.0" "version": "2.0.0"
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmRVYfZ7tWNHPBzWiG6KWGzvT2hcGems8srihsQE29x1U5", "hash": "QmVniQJkdzLZaZwzwMdd3dJTvWiJ1DQEkreVy6hs6h7Vk5",
"name": "go-smux-multistream", "name": "go-smux-multistream",
"version": "1.5.5" "version": "2.0.0"
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "Qmbn7RYyWzBVXiUp9jZ1dA4VADHy9DtS7iZLwfhEUQvm3U", "hash": "QmfTJ3UpS5ycNX7uQvPUSSRjGxk9EhUG7SyCstX6tCoNXS",
"name": "go-smux-yamux", "name": "go-smux-yamux",
"version": "1.2.0" "version": "2.0.0"
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
...@@ -69,15 +69,15 @@ ...@@ -69,15 +69,15 @@
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmVNPgPmEG4QKaDKkxMPKY34Z53n8efzv1sEh4NTsdhto7", "hash": "Qma1raveZpdRgcGkhzi1euLqmBgiVPNhHei1Ye39o7Joug",
"name": "go-peerstream", "name": "go-peerstream",
"version": "1.7.0" "version": "2.0.0"
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmVjRAPfRtResCMCE4eBqr4Beoa6A89P1YweG9wUS6RqUL", "hash": "QmQbh3Rb7KM37As3vkHYnEFnzkVXNCP8EYGtHz6g2fXk14",
"name": "go-libp2p-metrics", "name": "go-libp2p-metrics",
"version": "1.6.10" "version": "2.0.0"
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
...@@ -93,9 +93,9 @@ ...@@ -93,9 +93,9 @@
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmeZBgYBHvxMukGK5ojg28BCNLB9SeXqT7XXg6o7r2GbJy", "hash": "QmY9JXR3FupnYAYJWK9aMr9bCpqWKcToQ1tz8DVGTrHpHw",
"name": "go-stream-muxer", "name": "go-stream-muxer",
"version": "1.1.0" "version": "3.0.0"
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
...@@ -174,6 +174,6 @@ ...@@ -174,6 +174,6 @@
"license": "MIT", "license": "MIT",
"name": "go-libp2p-swarm", "name": "go-libp2p-swarm",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"", "releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "1.7.7" "version": "2.0.0"
} }
...@@ -12,7 +12,6 @@ import ( ...@@ -12,7 +12,6 @@ import (
"time" "time"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
pst "github.com/jbenet/go-stream-muxer"
"github.com/jbenet/goprocess" "github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context" goprocessctx "github.com/jbenet/goprocess/context"
addrutil "github.com/libp2p/go-addr-util" addrutil "github.com/libp2p/go-addr-util"
...@@ -27,6 +26,7 @@ import ( ...@@ -27,6 +26,7 @@ import (
transport "github.com/libp2p/go-libp2p-transport" transport "github.com/libp2p/go-libp2p-transport"
filter "github.com/libp2p/go-maddr-filter" filter "github.com/libp2p/go-maddr-filter"
ps "github.com/libp2p/go-peerstream" ps "github.com/libp2p/go-peerstream"
pst "github.com/libp2p/go-stream-muxer"
tcpt "github.com/libp2p/go-tcp-transport" tcpt "github.com/libp2p/go-tcp-transport"
ws "github.com/libp2p/go-ws-transport" ws "github.com/libp2p/go-ws-transport"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
......
...@@ -145,7 +145,7 @@ func (s *Swarm) addConnListener(list iconn.Listener) error { ...@@ -145,7 +145,7 @@ func (s *Swarm) addConnListener(list iconn.Listener) error {
// connHandler is called by the StreamSwarm whenever a new connection is added // connHandler is called by the StreamSwarm whenever a new connection is added
// here we configure it slightly. Note that this is sequential, so if anything // here we configure it slightly. Note that this is sequential, so if anything
// will take a while do it in a goroutine. // will take a while do it in a goroutine.
// See https://godoc.org/github.com/jbenet/go-peerstream for more information // See https://godoc.org/github.com/libp2p/go-peerstream for more information
func (s *Swarm) connHandler(c *ps.Conn) *Conn { func (s *Swarm) connHandler(c *ps.Conn) *Conn {
ctx := context.Background() ctx := context.Background()
// this context is for running the handshake, which -- when receiveing connections // this context is for running the handshake, which -- when receiveing connections
......
...@@ -125,7 +125,7 @@ func TestNotifications(t *testing.T) { ...@@ -125,7 +125,7 @@ func TestNotifications(t *testing.T) {
for _, s := range swarms { for _, s := range swarms {
s.SetStreamHandler(func(s inet.Stream) { s.SetStreamHandler(func(s inet.Stream) {
streams <- s streams <- s
s.Close() s.Reset()
}) })
} }
...@@ -139,7 +139,7 @@ func TestNotifications(t *testing.T) { ...@@ -139,7 +139,7 @@ func TestNotifications(t *testing.T) {
t.Error(err) t.Error(err)
} else { } else {
st1.Write([]byte("hello")) st1.Write([]byte("hello"))
st1.Close() st1.Reset()
testOCStream(notifiees[i], st1) testOCStream(notifiees[i], st1)
st2 := <-streams st2 := <-streams
testOCStream(n2, st2) testOCStream(n2, st2)
......
...@@ -43,6 +43,11 @@ func (s *Stream) Close() error { ...@@ -43,6 +43,11 @@ func (s *Stream) Close() error {
return s.Stream().Close() return s.Stream().Close()
} }
// Reset resets the stream, closing both ends.
func (s *Stream) Reset() error {
return s.Stream().Reset()
}
func (s *Stream) Protocol() protocol.ID { func (s *Stream) Protocol() protocol.ID {
return (*ps.Stream)(s).Protocol() return (*ps.Stream)(s).Protocol()
} }
......
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