195@@ -196,6 +196,11 @@ std::optional<bilingual_str> LoadAddrman(const std::vector<bool>& asmap, const A
196 addrman = std::make_unique<AddrMan>(asmap, /* deterministic */ false, /* consistency_check_ratio */ check_addrman);
197 LogPrintf("Creating peers.dat because the file was not found (%s)\n", fs::quoted(fs::PathToString(path_addr)));
198 DumpPeerAddresses(args, *addrman);
199+ } catch (const InvalidAddrManVersionError&) {
200+ // Addrman can be in an inconsistent state after failure, reset it
201+ addrman = std::make_unique<AddrMan>(asmap, /* deterministic */ false, /* consistency_check_ratio */ check_addrman);
202+ LogPrintf("Creating new peers.dat because the file version was not compatible (%s)\n", fs::quoted(fs::PathToString(path_addr)));
203+ DumpPeerAddresses(args, *addrman);
Would be nice to deduplicate the common code here somehow.
Maybe just a single common catch of std::exception, with if(DbNotFoundError) else if (InvalidAddrManVersionError) else return
then the common re-init logic?
👍 I will do a follow up once this is merged.