Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement the new network.MuxedConn interface #29

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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