From faefa5db5f1d95b772873f4429e8a8fbb4e71cf3 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 7 Dec 2020 14:01:19 +0100 Subject: [PATCH 1/2] log: Clarify that failure to write fee_estimates.dat is non-fatal --- src/policy/fees.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index f6e378866cb..1a57ddeee94 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -6,6 +6,8 @@ #include #include +#include +#include #include #include #include @@ -872,7 +874,7 @@ void CBlockPolicyEstimator::Flush() { fs::path est_filepath = GetDataDir() / FEE_ESTIMATES_FILENAME; CAutoFile est_file(fsbridge::fopen(est_filepath, "wb"), SER_DISK, CLIENT_VERSION); if (est_file.IsNull() || !Write(est_file)) { - LogPrintf("Failed to write fee estimates to %s\n", est_filepath.string()); + LogPrintf("Failed to write fee estimates to %s. Continue anyway.\n", est_filepath.string()); } } From fa0d8359b351fd179a0a2f458671a4d7828c9a80 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 7 Dec 2020 14:06:28 +0100 Subject: [PATCH 2/2] log: Clarify that failure to read fee_estimates.dat is non-fatal An uppercase "ERROR" in the log might indicate a fatal error. Though, all read-failures for fee_estimates.dat are non-fatal, so avoid the "ERROR". Before: ERROR: CBlockPolicyEstimator::Read(): up-version (149900) fee estimate file After: CBlockPolicyEstimator::Read(): unable to read policy estimator data (non-fatal): up-version (149900) fee estimate file --- src/policy/fees.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index 1a57ddeee94..cfa4cf84214 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -909,8 +909,9 @@ bool CBlockPolicyEstimator::Read(CAutoFile& filein) LOCK(m_cs_fee_estimator); int nVersionRequired, nVersionThatWrote; filein >> nVersionRequired >> nVersionThatWrote; - if (nVersionRequired > CLIENT_VERSION) - return error("CBlockPolicyEstimator::Read(): up-version (%d) fee estimate file", nVersionRequired); + if (nVersionRequired > CLIENT_VERSION) { + throw std::runtime_error(strprintf("up-version (%d) fee estimate file", nVersionRequired)); + } // Read fee estimates file into temporary variables so existing data // structures aren't corrupted if there is an exception. @@ -928,8 +929,9 @@ bool CBlockPolicyEstimator::Read(CAutoFile& filein) std::vector fileBuckets; filein >> fileBuckets; size_t numBuckets = fileBuckets.size(); - if (numBuckets <= 1 || numBuckets > 1000) + if (numBuckets <= 1 || numBuckets > 1000) { throw std::runtime_error("Corrupt estimates file. Must have between 2 and 1000 feerate buckets"); + } std::unique_ptr fileFeeStats(new TxConfirmStats(buckets, bucketMap, MED_BLOCK_PERIODS, MED_DECAY, MED_SCALE)); std::unique_ptr fileShortStats(new TxConfirmStats(buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE));