diff options
author | John Newbery <john@johnnewbery.com> | 2021-08-05 11:15:35 +0100 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2021-08-18 14:00:52 +0100 |
commit | e8e7392311edf44278d76743bebe902d4ac94662 (patch) | |
tree | d7b2db78ea0d261867dabed52be17d4c25ecd68b /src/init.cpp | |
parent | 181a1207ba6bd179d181f3e2534ef8676565ce72 (diff) | |
download | bitcoin-e8e7392311edf44278d76743bebe902d4ac94662.tar.xz |
[addrman] Don't call Clear() if parsing peers.dat fails
Now that we manage the lifespan of node.addrman, we can just reset
node.addrman to a newly initialized CAddrMan if parsing peers.dat
fails, eliminating the possibility that Clear() leaves some old state
behind.
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/init.cpp b/src/init.cpp index 2ca6cebee7..d741badc92 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1175,7 +1175,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) if (adb.Read(*node.addrman)) { LogPrintf("Loaded %i addresses from peers.dat %dms\n", node.addrman->size(), GetTimeMillis() - nStart); } else { - node.addrman->Clear(); // Addrman can be in an inconsistent state after failure, reset it + // Addrman can be in an inconsistent state after failure, reset it + node.addrman = std::make_unique<CAddrMan>(/* deterministic */ false, /* consistency_check_ratio */ check_addrman); LogPrintf("Recreating peers.dat\n"); adb.Write(*node.addrman); } |