Skip to main content

Module wire

Module wire 

Source
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§

Identify

Enums§

PbValue

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 data in its declared encoding (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 PublicKey protobuf. 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 than max fields 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