2019-05-22 17:31:11 +00:00
|
|
|
package network
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/libp2p/go-libp2p-core/mux"
|
|
|
|
"github.com/libp2p/go-libp2p-core/protocol"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Stream represents a bidirectional channel between two agents in
|
|
|
|
// a libp2p network. "agent" is as granular as desired, potentially
|
|
|
|
// being a "request -> reply" pair, or whole protocols.
|
|
|
|
//
|
|
|
|
// Streams are backed by a multiplexer underneath the hood.
|
|
|
|
type Stream interface {
|
|
|
|
mux.MuxedStream
|
|
|
|
|
2020-06-05 11:24:56 +00:00
|
|
|
// ID returns an identifier that uniquely identifies this Stream within this
|
|
|
|
// host, during this run. Stream IDs may repeat across restarts.
|
|
|
|
ID() string
|
|
|
|
|
2019-05-22 17:31:11 +00:00
|
|
|
Protocol() protocol.ID
|
|
|
|
SetProtocol(id protocol.ID)
|
|
|
|
|
|
|
|
// Stat returns metadata pertaining to this stream.
|
2021-12-12 10:58:02 +00:00
|
|
|
Stat() Stats
|
2019-05-22 17:31:11 +00:00
|
|
|
|
|
|
|
// Conn returns the connection this stream is part of.
|
|
|
|
Conn() Conn
|
|
|
|
}
|