libp2p.stream_muxer package

Submodules module

class, peer_id:

Bases: abc.ABC


abstract async accept_stream() →

accepts a muxed stream opened by the other end.

abstract async close() → None

close connection.

event_started: trio.Event = None
abstract property is_closed

check connection is fully closed.


true if successful

abstract property is_initiator

if this connection is the initiator.

abstract async open_stream() →

creates a new muxed_stream.


a new IMuxedStream stream

peer_id: ID = None
abstract async start() → None

start the multiplexer.



muxed_conn: IMuxedConn = None
abstract async reset() → None

closes both ends of the stream tells this remote side to hang up.

abstract set_deadline(ttl: int) → bool

set deadline for muxed stream.


a new stream

libp2p.stream_muxer.exceptions module

exception libp2p.stream_muxer.exceptions.MuxedConnError

Bases: libp2p.exceptions.BaseLibp2pError

exception libp2p.stream_muxer.exceptions.MuxedConnUnavailable

Bases: libp2p.stream_muxer.exceptions.MuxedConnError

exception libp2p.stream_muxer.exceptions.MuxedStreamClosed

Bases: libp2p.stream_muxer.exceptions.MuxedStreamError

exception libp2p.stream_muxer.exceptions.MuxedStreamEOF

Bases: libp2p.stream_muxer.exceptions.MuxedStreamError, EOFError

exception libp2p.stream_muxer.exceptions.MuxedStreamError

Bases: libp2p.exceptions.BaseLibp2pError

exception libp2p.stream_muxer.exceptions.MuxedStreamReset

Bases: libp2p.stream_muxer.exceptions.MuxedStreamError

libp2p.stream_muxer.muxer_multistream module

class libp2p.stream_muxer.muxer_multistream.MuxerMultistream(muxer_transports_by_protocol: Mapping[NewType.<locals>.new_type, Type[]])

Bases: object

MuxerMultistream is a multistream stream muxed transport multiplexer.

go implementation:

add_transport(protocol: NewType.<locals>.new_type, transport: Type[]) → None

Add a protocol and its corresponding transport to multistream- select(multiselect). The order that a protocol is added is exactly the precedence it is negotiated in multiselect.

  • protocol – the protocol name, which is negotiated in multiselect.

  • transport – the corresponding transportation to the protocol.

multiselect: Multiselect = None
multiselect_client: MultiselectClient = None
async new_conn(conn:, peer_id: →
async select_transport(conn: → Type[]

Select a transport that both us and the node on the other end of conn support and agree on.


conn – conn to choose a transport over


selected muxer transport

transports: 'OrderedDict[TProtocol, TMuxerClass]' = None

Module contents