Peer record size bounding and serialization
masterTo maintain predictable message sizes on the wire and in the peerstore, this implementation bounds single peer records (a Peer ID plus its multiaddresses) to a maximum of 8 KiB during serialization.
When a record exceeds this limit, the implementation keeps the Peer ID and as many addresses as fit, dropping any remaining addresses. This 8 KiB ceiling is designed to be larger than any well-formed peer's signed self-description provided via the libp2p identify protocol.
This bounding applies to both:
- Records this node emits.
- Records this node ingests from other peers.
Because a trimmed record is simply a standard, smaller peer record, this optimization is compatible with all other Kademlia implementations without requiring coordination.