Alternative to #20509.
This makes the CAddress
disk serialization format well defined, and uses it to enable addrv2 support in anchors.dat (in a way that’s compatible with older software). The new format is:
- The first 4 bytes store a format version number. Its low 19 bits are ignored (as those historically stored the
CLIENT_VERSION
), but its high 13 bits specify the actual serialization:- 0x00000000: LE64 encoding for
nServices
, V1 encoding forCService
(like pre-BIP155 network serialization). - 0x20000000: CompactSize encoding for
nServices
, V2 encoding forCService
(like BIP155 network serialization). - Any other value triggers an unsupported format error on deserialization, and can be used for future format changes.
- 0x00000000: LE64 encoding for
- The
ADDRV2_FORMAT
flag in the stream’s version does not determine the actual serialization format; it only sets whether or not V2 encoding is permitted.