Skip to main content

Module host

Module host 

Source
Expand description

One libp2p connection, either role: upgrading TCP to Noise and yamux, answering the peer’s identify, identify-push and ping streams in Rust, and turning the application protocols’ streams into messages (uvarint-length-prefixed, the libp2p convention).

Structs§

Config
Peer
A live connection: what actions need to open, write and close streams.
Remote
What the remote said about itself.

Enums§

Note
What a connection’s streams report to whoever answers for it.

Constants§

AGENT
DEFAULT_PROTOCOLS
The application protocol a host speaks when none is configured.
MAX_MESSAGE
One application message is at most this long (go-msgio’s own default is 8 MiB; NetGet hands each to a model).
MAX_REMEMBERED_STREAMS
Streams whose writers a connection keeps for actions.
NEGOTIATION_TIMEOUT
Negotiating security, the multiplexer, or a stream’s protocol.
PING_SIZE
A ping is 32 random bytes echoed back.
PROTOCOL_VERSION

Functions§

accept_streams
Serve every stream the peer opens until the connection ends.
identify
Ask the remote’s identify.
open_app_stream
Open a stream for an application protocol; None when the peer refuses the protocol. Its messages arrive as notes, read by the task this returns.
open_negotiated
Open a stream proposing each of protocols in turn: the stream and the protocol the peer accepted, or None when it accepts none of them. The caller owns the stream.
ping
Ping the remote once: the round trip.
read_messages
Turn a stream’s messages (each at most max bytes) into notes until the peer closes it.
send
Write one message to a stream this connection has open.
upgrade_inbound
Listener side: select /noise, handshake as responder, select /yamux/1.0.0.
upgrade_outbound
Dialler side; expected is the peer id the address named, if any.

Type Aliases§

Directory
Connected peers (base58 id) and their listen addresses (binary multiaddrs).
Spawn
Spawns a task owned by the server or client this connection belongs to.
Task