From faf48f20f196e418b2eea390a0140db3604cfa15 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 18 Feb 2021 13:34:18 +0100 Subject: [PATCH] log: Clarify log message when file does not exist Also, run clang-format on the function --- src/addrdb.cpp | 12 ++++++------ src/banman.cpp | 2 +- src/net.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/addrdb.cpp b/src/addrdb.cpp index 8f77ed35ce5..0922c1c432b 100644 --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -109,15 +109,15 @@ template bool DeserializeFileDB(const fs::path& path, Data& data) { // open input file, and associate with CAutoFile - FILE *file = fsbridge::fopen(path, "rb"); + FILE* file = fsbridge::fopen(path, "rb"); CAutoFile filein(file, SER_DISK, CLIENT_VERSION); - if (filein.IsNull()) - return error("%s: Failed to open file %s", __func__, path.string()); - + if (filein.IsNull()) { + LogPrintf("Missing or invalid file %s\n", path.string()); + return false; + } return DeserializeDB(filein, data); } - -} +} // namespace CBanDB::CBanDB(fs::path ban_list_path) : m_ban_list_path(std::move(ban_list_path)) { diff --git a/src/banman.cpp b/src/banman.cpp index 49bf6c43dce..3fe561ad018 100644 --- a/src/banman.cpp +++ b/src/banman.cpp @@ -28,7 +28,7 @@ BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t LogPrint(BCLog::NET, "Loaded %d banned node ips/subnets from banlist.dat %dms\n", m_banned.size(), GetTimeMillis() - n_start); } else { - LogPrintf("Invalid or missing banlist.dat; recreating\n"); + LogPrintf("Recreating banlist.dat\n"); SetBannedSetDirty(true); // force write DumpBanlist(); } diff --git a/src/net.cpp b/src/net.cpp index 81176785a27..fc503e974ca 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2391,7 +2391,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions) 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("Invalid or missing peers.dat; recreating\n"); + LogPrintf("Recreating peers.dat\n"); DumpAddresses(); } }