CompactNodes
Encode/decode of the compact nodes strings that BEP-5 queries return: the counterpart to libtorrent's write_nodes_entry and the inline decode loops in find_data / the routing table's read_nodes. The IPv4 form ("n4"/nodes, 26-byte records) and the IPv6 form ("n6"/nodes6, 38-byte records) are encoded here separately because the record width is fixed per family.
Properties
Functions
Decode a nodes string of fixed-width IPv4 records (26 bytes each). Any trailing partial record is ignored, matching libtorrent's while (end - in >= 26) style loops.
Decode a nodes6 string of fixed-width IPv6 records (38 bytes each). Any trailing partial record is ignored.
Concatenate the compact form of every node in nodes into one byte string: a direct port of write_nodes_entry. Each record is id || write_endpoint(ep). The nodes may freely mix v4/v6 (libtorrent keeps them in separate keys, but the encoding itself is just self-describing-width records).