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
protocolsin 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
maxbytes) 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;
expectedis the peer id the address named, if any.