The new anchors.dat file stores a vector of CAddress
objects, and doesn’t set ADDRV2_FORMAT. That means that torv3 and other addrv2 network types won’t be serialized correctly in it. It would be good to address this in 0.21.
Now, CAddress does have a version field, which can be used to signal the encoding. In the current code, on serialization that value stores whether ADDRV2_FORMAT is set or not, and on deserialization that value is inspected to determine which deserializer to use. #20509 was just opened to change this, and that may complicate matters.
That means there are a number of possible solutions here:
- Make CAddress deserialization use the context version rather than the disk version (20509) and make anchors.dat always use ADDRV2_FORMAT. This means potential problems too if there is ever an addrv3.
- Make anchors.dat always set ADDRV2_FORMAT, but keep using the stored disk version at deserialization time. That’s incompatible with 20509, but an easier fix for 0.21.
- Change the
anchors.dat
file format to have a version number. That could be done now (but is a pretty invasive change at rc3…), or could be done later by encoding it as an “invalid CAddress” first as a marker…