Skip to content

Commit 1fe67ad

Browse files
implement the new network.MuxedConn interface
1 parent f0fa15e commit 1fe67ad

File tree

5 files changed

+71
-55
lines changed

5 files changed

+71
-55
lines changed

conn.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ package peerstream_multiplex
33
import (
44
"context"
55

6-
"github.com/libp2p/go-libp2p-core/mux"
6+
"github.com/libp2p/go-libp2p-core/network"
7+
78
mp "github.com/libp2p/go-mplex"
89
)
910

1011
type conn mp.Multiplex
1112

13+
var _ network.MuxedConn = &conn{}
14+
1215
func (c *conn) Close() error {
1316
return c.mplex().Close()
1417
}
@@ -18,7 +21,7 @@ func (c *conn) IsClosed() bool {
1821
}
1922

2023
// OpenStream creates a new stream.
21-
func (c *conn) OpenStream(ctx context.Context) (mux.MuxedStream, error) {
24+
func (c *conn) OpenStream(ctx context.Context) (network.MuxedStream, error) {
2225
s, err := c.mplex().NewStream(ctx)
2326
if err != nil {
2427
return nil, err
@@ -27,7 +30,7 @@ func (c *conn) OpenStream(ctx context.Context) (mux.MuxedStream, error) {
2730
}
2831

2932
// AcceptStream accepts a stream opened by the other side.
30-
func (c *conn) AcceptStream() (mux.MuxedStream, error) {
33+
func (c *conn) AcceptStream() (network.MuxedStream, error) {
3134
s, err := c.mplex().Accept()
3235
if err != nil {
3336
return nil, err
@@ -38,5 +41,3 @@ func (c *conn) AcceptStream() (mux.MuxedStream, error) {
3841
func (c *conn) mplex() *mp.Multiplex {
3942
return (*mp.Multiplex)(c)
4043
}
41-
42-
var _ mux.MuxedConn = &conn{}

go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/libp2p/go-libp2p-mplex
33
go 1.16
44

55
require (
6-
github.com/libp2p/go-libp2p-core v0.8.0
7-
github.com/libp2p/go-libp2p-testing v0.4.0
8-
github.com/libp2p/go-mplex v0.3.0
6+
github.com/libp2p/go-libp2p-core v0.14.0
7+
github.com/libp2p/go-libp2p-testing v0.7.0
8+
github.com/libp2p/go-mplex v0.3.1-0.20220117112902-3f6e5a4adc58
99
)

0 commit comments

Comments
 (0)