Skip to content

Commit dcff2ee

Browse files
committed
Merge #20589: log: Clarify that failure to read/write fee_estimates.dat is non-fatal
fa0d835 log: Clarify that failure to read fee_estimates.dat is non-fatal (MarcoFalke) faefa5d log: Clarify that failure to write fee_estimates.dat is non-fatal (MarcoFalke) Pull request description: two minor logging fixups ACKs for top commit: practicalswift: ACK fa0d835: patch looks correct laanwj: Code review ACK fa0d835 Tree-SHA512: d1e7e595d3b4a5e497ee7ab70f3be5783dafec2726ef8e012db836c15e8e622022859a4472d6b516fe19d327737b25fdfb509cd9aeb022ca847b13c54e55800a
2 parents eb53c03 + fa0d835 commit dcff2ee

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/policy/fees.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <policy/fees.h>
77

88
#include <clientversion.h>
9+
#include <fs.h>
10+
#include <logging.h>
911
#include <streams.h>
1012
#include <txmempool.h>
1113
#include <util/system.h>
@@ -872,7 +874,7 @@ void CBlockPolicyEstimator::Flush() {
872874
fs::path est_filepath = GetDataDir() / FEE_ESTIMATES_FILENAME;
873875
CAutoFile est_file(fsbridge::fopen(est_filepath, "wb"), SER_DISK, CLIENT_VERSION);
874876
if (est_file.IsNull() || !Write(est_file)) {
875-
LogPrintf("Failed to write fee estimates to %s\n", est_filepath.string());
877+
LogPrintf("Failed to write fee estimates to %s. Continue anyway.\n", est_filepath.string());
876878
}
877879
}
878880

@@ -907,8 +909,9 @@ bool CBlockPolicyEstimator::Read(CAutoFile& filein)
907909
LOCK(m_cs_fee_estimator);
908910
int nVersionRequired, nVersionThatWrote;
909911
filein >> nVersionRequired >> nVersionThatWrote;
910-
if (nVersionRequired > CLIENT_VERSION)
911-
return error("CBlockPolicyEstimator::Read(): up-version (%d) fee estimate file", nVersionRequired);
912+
if (nVersionRequired > CLIENT_VERSION) {
913+
throw std::runtime_error(strprintf("up-version (%d) fee estimate file", nVersionRequired));
914+
}
912915

913916
// Read fee estimates file into temporary variables so existing data
914917
// structures aren't corrupted if there is an exception.
@@ -926,8 +929,9 @@ bool CBlockPolicyEstimator::Read(CAutoFile& filein)
926929
std::vector<double> fileBuckets;
927930
filein >> fileBuckets;
928931
size_t numBuckets = fileBuckets.size();
929-
if (numBuckets <= 1 || numBuckets > 1000)
932+
if (numBuckets <= 1 || numBuckets > 1000) {
930933
throw std::runtime_error("Corrupt estimates file. Must have between 2 and 1000 feerate buckets");
934+
}
931935

932936
std::unique_ptr<TxConfirmStats> fileFeeStats(new TxConfirmStats(buckets, bucketMap, MED_BLOCK_PERIODS, MED_DECAY, MED_SCALE));
933937
std::unique_ptr<TxConfirmStats> fileShortStats(new TxConfirmStats(buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE));

0 commit comments

Comments
 (0)