libp2p.network.connection package

Submodules

libp2p.network.connection.exceptions module

exception libp2p.network.connection.exceptions.RawConnError

Bases: IOException

libp2p.network.connection.raw_connection module

class libp2p.network.connection.raw_connection.RawConnection(stream: ReadWriteCloser, initiator: bool)

Bases: IRawConnection

async close() None
get_remote_address() tuple[str, int] | None

Delegate to the underlying stream’s get_remote_address method.

is_initiator: bool
async read(n: int | None = None) bytes

Read up to n bytes from the underlying stream. This call is delegated directly to the underlying self.reader.

Raise RawConnError if the underlying connection breaks

stream: ReadWriteCloser
async write(data: bytes) None

Raise RawConnError if the underlying connection breaks.

libp2p.network.connection.swarm_connection module

class libp2p.network.connection.swarm_connection.SwarmConn(muxed_conn: IMuxedConn, swarm: Swarm)

Bases: INetConn

async close() None
event_closed: Event
get_streams() tuple[NetStream, ...]

Retrieve all active streams associated with this connection.

Returns:

A tuple containing instances of INetStream.

get_transport_addresses() list[Multiaddr]

Retrieve the transport addresses used by this connection.

Returns

list[Multiaddr]

A list of multiaddresses used by the transport.

property is_closed: bool
muxed_conn: IMuxedConn
async new_stream() NetStream

Create a new network stream over the connection.

Returns:

A new instance of INetStream.

remove_stream(stream: NetStream) None
set_resource_scope(scope: Any) None

Set the resource scope for this connection.

async start() None
streams: set[NetStream]
swarm: Swarm

Module contents