Expand description
libp2p host (server role): accepts TCP connections, upgrades them to Noise and yamux, answers identify and ping in Rust, and hands every message on the application protocols’ streams to the model, one connection’s events at a time.
Modules§
- actions
- What the model does as a libp2p host: answer messages on the application protocols’ streams, open streams of its own to a connected peer, close them, and drop peers. Rust owns the transport (Noise, yamux, multistream-select) and answers identify and ping.
- bitswap
- Bitswap 1.2.0 (and 1.1.0, 1.0.0): the message, and the two decisions Rust makes about it
before or after the model — which wanted blocks the model’s content actually is
(
answer_wants), and which received blocks are the ones that were asked for (accept_blocks). In both, a block’s identity is its hash, computed here. - host
- 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).
- ipfs
- The IPFS data model, minimally: multihashes (sha2-256 only), CIDv0 and CIDv1 in binary and
text (base58btc, and base32 as
b…), therawanddag-pbcodecs, and UnixFS nodes. - kad
- The Kademlia DHT message (
/ipfs/kad/1.0.0, and the LAN DHT’s/ipfs/lan/kad/1.0.0): one uvarint-length-prefixed protobuf per request, answered on the same stream. Peers are carried as (peer id, binary multiaddrs); both are checked on the way in and out. - noise
- libp2p’s Noise channel:
Noise_XX_25519_ChaChaPoly_SHA256with an empty prologue, each message framed by a 16-bit big-endian length, and the libp2p handshake payload (the identity key and its signature over the Noise static key) in messages 2 and 3. - wire
- The small libp2p encodings, shared by both roles: unsigned varints, the protobuf fields libp2p uses, base58btc peer ids, binary multiaddrs, multistream-select 1.0 and the identify message. Each decoder bounds what the peer may announce.
- yamux
- yamux (the hashicorp spec,
/yamux/1.0.0) over a Noise channel. One task reads frames and routes them to streams; one task owns the writer and every stream’s send window, so data the peer has no window for waits there rather than being sent past its limit.
Constants§
- NOTE_
QUEUE - Notes (messages, closes) queued for one connection’s model before its streams wait.
Functions§
- identity_
from_ params - The identity a
private_key_seednames: SHA-256 of the text is the Ed25519 seed, so the same text always gives the same peer id. None: a new key. - protocols_
from_ params - spawn