Skip to content

Commit

Permalink
implement the new network.MuxedConn interface
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jan 17, 2022
1 parent f0fa15e commit ad6d87e
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 68 deletions.
11 changes: 6 additions & 5 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ package peerstream_multiplex
import (
"context"

"github.com/libp2p/go-libp2p-core/mux"
"github.com/libp2p/go-libp2p-core/network"

mp "github.com/libp2p/go-mplex"
)

type conn mp.Multiplex

var _ network.MuxedConn = &conn{}

func (c *conn) Close() error {
return c.mplex().Close()
}
Expand All @@ -18,7 +21,7 @@ func (c *conn) IsClosed() bool {
}

// OpenStream creates a new stream.
func (c *conn) OpenStream(ctx context.Context) (mux.MuxedStream, error) {
func (c *conn) OpenStream(ctx context.Context) (network.MuxedStream, error) {
s, err := c.mplex().NewStream(ctx)
if err != nil {
return nil, err
Expand All @@ -27,7 +30,7 @@ func (c *conn) OpenStream(ctx context.Context) (mux.MuxedStream, error) {
}

// AcceptStream accepts a stream opened by the other side.
func (c *conn) AcceptStream() (mux.MuxedStream, error) {
func (c *conn) AcceptStream() (network.MuxedStream, error) {
s, err := c.mplex().Accept()
if err != nil {
return nil, err
Expand All @@ -38,5 +41,3 @@ func (c *conn) AcceptStream() (mux.MuxedStream, error) {
func (c *conn) mplex() *mp.Multiplex {
return (*mp.Multiplex)(c)
}

var _ mux.MuxedConn = &conn{}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/libp2p/go-libp2p-mplex
go 1.16

require (
github.com/libp2p/go-libp2p-core v0.8.0
github.com/libp2p/go-libp2p-testing v0.4.0
github.com/libp2p/go-mplex v0.3.0
github.com/libp2p/go-libp2p-core v0.14.0
github.com/libp2p/go-libp2p-testing v0.7.0
github.com/libp2p/go-mplex v0.4.0
)
Loading

0 comments on commit ad6d87e

Please sign in to comment.