Skip to content

Commit

Permalink
Merge pull request #20 from libp2p/feat/stream-interfaces
Browse files Browse the repository at this point in the history
feat: update stream interfaces
  • Loading branch information
Stebalien committed Sep 2, 2020
2 parents 8a4d7ec + f4aa298 commit fdb9a0a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 10 additions & 2 deletions p2p/muxer/mplex/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@ func (c *conn) IsClosed() bool {

// OpenStream creates a new stream.
func (c *conn) OpenStream() (mux.MuxedStream, error) {
return c.mplex().NewStream()
s, err := c.mplex().NewStream()
if err != nil {
return nil, err
}
return (*stream)(s), nil
}

// AcceptStream accepts a stream opened by the other side.
func (c *conn) AcceptStream() (mux.MuxedStream, error) {
return c.mplex().Accept()
s, err := c.mplex().Accept()
if err != nil {
return nil, err
}
return (*stream)(s), nil
}

func (c *conn) mplex() *mp.Multiplex {
Expand Down
8 changes: 8 additions & 0 deletions p2p/muxer/mplex/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ func (s *stream) Close() error {
return s.mplex().Close()
}

func (s *stream) CloseWrite() error {
return s.mplex().CloseWrite()
}

func (s *stream) CloseRead() error {
return s.mplex().CloseRead()
}

func (s *stream) Reset() error {
return s.mplex().Reset()
}
Expand Down

0 comments on commit fdb9a0a

Please sign in to comment.