mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
[addrman] Move peers.dat parsing to init.cpp
This commit is contained in:
parent
e35c4a3d80
commit
181a1207ba
13
src/init.cpp
13
src/init.cpp
@ -1167,6 +1167,19 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||
assert(!node.addrman);
|
||||
auto check_addrman = std::clamp<int32_t>(args.GetArg("-checkaddrman", DEFAULT_ADDRMAN_CONSISTENCY_CHECKS), 0, 1000000);
|
||||
node.addrman = std::make_unique<CAddrMan>(/* deterministic */ false, /* consistency_check_ratio */ check_addrman);
|
||||
{
|
||||
// Load addresses from peers.dat
|
||||
uiInterface.InitMessage(_("Loading P2P addresses…").translated);
|
||||
int64_t nStart = GetTimeMillis();
|
||||
CAddrDB adb;
|
||||
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
|
||||
LogPrintf("Recreating peers.dat\n");
|
||||
adb.Write(*node.addrman);
|
||||
}
|
||||
}
|
||||
assert(!node.banman);
|
||||
node.banman = std::make_unique<BanMan>(gArgs.GetDataDirNet() / "banlist", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
|
||||
assert(!node.connman);
|
||||
|
16
src/net.cpp
16
src/net.cpp
@ -2534,22 +2534,6 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
|
||||
AddAddrFetch(strDest);
|
||||
}
|
||||
|
||||
if (m_client_interface) {
|
||||
m_client_interface->InitMessage(_("Loading P2P addresses…").translated);
|
||||
}
|
||||
// Load addresses from peers.dat
|
||||
int64_t nStart = GetTimeMillis();
|
||||
{
|
||||
CAddrDB adb;
|
||||
if (adb.Read(addrman))
|
||||
LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman.size(), GetTimeMillis() - nStart);
|
||||
else {
|
||||
addrman.Clear(); // Addrman can be in an inconsistent state after failure, reset it
|
||||
LogPrintf("Recreating peers.dat\n");
|
||||
DumpAddresses();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_use_addrman_outgoing) {
|
||||
// Load addresses from anchors.dat
|
||||
m_anchors = ReadAnchors(gArgs.GetDataDirNet() / ANCHORS_DATABASE_FILENAME);
|
||||
|
Loading…
Reference in New Issue
Block a user