add a context to OpenStream and NewStream (#172)

* add a context to MuxedConn.OpenStream

* add a context to Conn.NewStream
This commit is contained in:
Marten Seemann 2020-12-19 09:36:59 +07:00 committed by GitHub
parent a39b84ea2e
commit 83ac1d370d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -5,6 +5,7 @@
package mux
import (
"context"
"errors"
"io"
"net"
@ -74,7 +75,7 @@ type MuxedConn interface {
IsClosed() bool
// OpenStream creates a new stream.
OpenStream() (MuxedStream, error)
OpenStream(context.Context) (MuxedStream, error)
// AcceptStream accepts a stream opened by the other side.
AcceptStream() (MuxedStream, error)

View File

@ -1,6 +1,7 @@
package network
import (
"context"
"io"
ic "github.com/libp2p/go-libp2p-core/crypto"
@ -24,7 +25,7 @@ type Conn interface {
ID() string
// NewStream constructs a new Stream over this conn.
NewStream() (Stream, error)
NewStream(context.Context) (Stream, error)
// GetStreams returns all open streams over this conn.
GetStreams() []Stream