Skip to main content

Module entry

Module entry 

Source
Expand description

The peer entry — the unit of exchange (SPEC §3). It is the L7 PeerRecord shape extended with a flags list, carrying a peer_id, candidate addresses, the network_id, a last_seen Unix-seconds timestamp, a via provenance, and per-peer capability flags.

§Byte-compatibility

Address ({ host, port, kind }) is byte-compatible with the L7 dig.getPeers addresses and the dig-nat / dig-gossip / dig-dht Contact address shape — same JSON field names and the same kind tokens (direct | mapped | reflexive | relay). It is mirrored here (rather than importing those crates) to keep the PEX dependency surface minimal; the wire form MUST stay identical so a returned entry drops straight into a dial target.

§Tolerant decode, strict validation

Inbound entries decode tolerantly: an unrecognized kind or via token deserializes to the AddressKind::Unknown / Provenance::Unknown catch-all rather than failing the whole message, and every field has a default. This is what makes a malformed entry skipped, not fatal (SPEC §3.3, §7.3): PeerEntry::validate decides keep-or-skip; a broken token never aborts the sibling entries around it.

Structs§

Address
One candidate address for a peer: { host, port, kind } (SPEC §3.1). Byte-compatible with the L7 dig.getPeers / DHT Contact address shape.
PeerEntry
The unit of exchange — a peer entry (SPEC §3). Constructed via PeerEntry::new + the builder methods for outgoing advertisements; decoded tolerantly for inbound validation.
ValidateCtx
The receiver-side context an inbound entry is validated against (SPEC §3.3).

Enums§

AddressKind
How a candidate address was learned — the L7 dig.getPeers addresses[].kind tokens (SPEC §3.1). The lowercase serde spelling is the frozen wire form.
Provenance
The advertiser’s provenance for an entry (SPEC §3.1, §8.1) — how it knows the peer first-hand. There is deliberately no "pex" token: an entry known only via PEX has no legitimate via to claim, which is what stops re-gossip amplification (SPEC §8.1).

Functions§

is_hex64
Whether s is exactly 64 lowercase hexadecimal characters (<64hex>, SPEC §2).