Expand description
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.
Structs§
Enums§
Constants§
- IDENTIFY
- IDENTIFY_
PUSH - MAX_
IDENTIFY_ BYTES - An identify message is at most this long (go-libp2p’s own limit is 8 KiB of protobuf plus the signed peer record; leave room for both).
- MAX_
MULTISTREAM_ MESSAGE - A multistream-select message (a protocol id and its newline) is at most this long.
- MAX_
PROPOSALS - Proposals a listener answers on one stream before giving up on it.
- MULTISTREAM
- NOISE
- PING
- YAMUX
Traits§
- Io
- Byte-stream I/O that every libp2p layer offers the one above it.
Functions§
- base58
- data_
bytes - An action’s
datain its declaredencoding(utf8 by default, or hex). - decode_
identify - ed25519_
public_ key_ proto PublicKey{Type: Ed25519, Data: key}, the form a peer id hashes.- encode_
identify - get_
uvarint - Decode a uvarint at the start of
b: (value, bytes used). - length_
prefixed - ms_dial
- Propose
protocol; Ok(true) when the listener accepts it, Ok(false) on “na”. - ms_
dial_ any - Propose each protocol in turn on one stream; the first the listener accepts, or None when it refuses them all.
- ms_
listen - Answer a dialer’s proposals until one is supported; returns it.
- multiaddr_
bytes - multiaddr_
from_ text - A text multiaddr in binary:
/ip4|ip6/…,/tcp|udp/…,/quic-v1,/p2p/<id>, in any order the text gives them. Anything else is refused rather than guessed. - multiaddr_
string - multiaddr_
text - A binary multiaddr as text; components outside the subset are shown by code.
- parse_
dial_ target host:port,/ip4/a/tcp/p[/p2p/id]or/ip6/…: the address to dial and the expected peer id, if named.- parse_
public_ key - The Ed25519 key inside a
PublicKeyprotobuf. Other key types are refused. - pb_
bytes - pb_
fields - Every (field, value) in a message; unknown wire types are an error, fixed-width ones are skipped.
- pb_
fields_ bounded pb_fields, refusing a message with more thanmaxfields before collecting them, so a peer cannot turn a few megabytes of two-byte fields into a vector many times larger.- pb_
varint - peer_id
- The peer id of a public key protobuf: an identity multihash, since every Ed25519 key’s protobuf is 36 bytes (≤ 42).
- peer_
id_ string - put_
uvarint - read_
length_ prefixed - A uvarint-length-prefixed message, refused before reading past
max. - read_
uvarint - Read one uvarint from a stream (at most 9 bytes: 63 bits).
- shown
- Message bytes as the model sees them: text, or hex when they are not printable UTF-8.
- unbase58