Skip to content

Commit

Permalink
Merge pull request #35 from libp2p/feat/update-stream-muxer
Browse files Browse the repository at this point in the history
Update stream muxer.
  • Loading branch information
whyrusleeping authored Sep 13, 2017
2 parents 707639d + 10de0c3 commit 1dfbb4e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion p2p/net/swarm/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

logging "github.com/ipfs/go-log"
pst "github.com/jbenet/go-stream-muxer"
"github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context"
addrutil "github.com/libp2p/go-addr-util"
Expand All @@ -27,6 +26,7 @@ import (
transport "github.com/libp2p/go-libp2p-transport"
filter "github.com/libp2p/go-maddr-filter"
ps "github.com/libp2p/go-peerstream"
pst "github.com/libp2p/go-stream-muxer"
tcpt "github.com/libp2p/go-tcp-transport"
ws "github.com/libp2p/go-ws-transport"
ma "github.com/multiformats/go-multiaddr"
Expand Down
2 changes: 1 addition & 1 deletion p2p/net/swarm/swarm_listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (s *Swarm) addConnListener(list iconn.Listener) error {
// 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
// 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 {
ctx := context.Background()
// this context is for running the handshake, which -- when receiveing connections
Expand Down
4 changes: 2 additions & 2 deletions p2p/net/swarm/swarm_notif_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestNotifications(t *testing.T) {
for _, s := range swarms {
s.SetStreamHandler(func(s inet.Stream) {
streams <- s
s.Close()
s.Reset()
})
}

Expand All @@ -139,7 +139,7 @@ func TestNotifications(t *testing.T) {
t.Error(err)
} else {
st1.Write([]byte("hello"))
st1.Close()
st1.Reset()
testOCStream(notifiees[i], st1)
st2 := <-streams
testOCStream(n2, st2)
Expand Down
5 changes: 5 additions & 0 deletions p2p/net/swarm/swarm_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ func (s *Stream) Close() error {
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 {
return (*ps.Stream)(s).Protocol()
}
Expand Down

0 comments on commit 1dfbb4e

Please sign in to comment.