libp2p.stream_muxer.mplex package
Submodules
libp2p.stream_muxer.mplex.constants module
libp2p.stream_muxer.mplex.datastructures module
libp2p.stream_muxer.mplex.exceptions module
- exception libp2p.stream_muxer.mplex.exceptions.MplexError
Bases:
MuxedConnError
- exception libp2p.stream_muxer.mplex.exceptions.MplexStreamClosed
Bases:
MuxedStreamClosed
- exception libp2p.stream_muxer.mplex.exceptions.MplexStreamEOF
Bases:
MuxedStreamEOF
- exception libp2p.stream_muxer.mplex.exceptions.MplexStreamReset
Bases:
MuxedStreamReset
Bases:
MuxedConnUnavailable
libp2p.stream_muxer.mplex.mplex module
- class libp2p.stream_muxer.mplex.mplex.Mplex(secured_conn: ISecureConn, peer_id: ID)
Bases:
IMuxedConn
reference: https://github.com/libp2p/go-mplex/blob/master/multiplex.go
- async accept_stream() IMuxedStream
Accept a muxed stream opened by the other end.
- event_closed: Event
- event_shutting_down: Event
- event_started: Event
- async handle_incoming() None
Read a message off of the secured connection and add it to the corresponding message buffer.
- new_stream_receive_channel: trio.MemoryReceiveChannel[IMuxedStream]
- new_stream_send_channel: trio.MemorySendChannel[IMuxedStream]
- async open_stream() IMuxedStream
Create a new muxed_stream.
- Returns:
a new
MplexStream
- async read_message() Tuple[int, int, bytes]
Read a single message off of the secured connection.
- Returns:
stream_id, flag, message contents
- secured_conn: ISecureConn
- async send_message(flag: HeaderTags, data: bytes | None, stream_id: StreamID) int
Send a message over the connection.
- Parameters:
flag – header to use
data – data to send in the message
stream_id – stream the message is in
- streams: Dict[StreamID, MplexStream]
- streams_lock: Lock
libp2p.stream_muxer.mplex.mplex_stream module
- class libp2p.stream_muxer.mplex.mplex_stream.MplexStream(name: str, stream_id: StreamID, muxed_conn: Mplex, incoming_data_channel: trio.MemoryReceiveChannel[bytes])
Bases:
IMuxedStream
reference: https://github.com/libp2p/go-mplex/blob/master/stream.go
- async close() None
Closing a stream closes it for writing and closes the remote end for reading but allows writing in the other direction.
- close_lock: Lock
- event_local_closed: Event
- event_remote_closed: Event
- event_reset: Event
- async read(n: int | None = None) bytes
Read up to n bytes. Read possibly returns fewer than n bytes, if there are not enough bytes in the Mplex buffer. If n is None, read until EOF.
- Parameters:
n – number of bytes to read
- Returns:
bytes actually read