mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #20589: log: Clarify that failure to read/write fee_estimates.dat is non-fatal
fa0d8359b351fd179a0a2f458671a4d7828c9a80 log: Clarify that failure to read fee_estimates.dat is non-fatal (MarcoFalke) faefa5db5f1d95b772873f4429e8a8fbb4e71cf3 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 fa0d8359b351fd179a0a2f458671a4d7828c9a80: patch looks correct laanwj: Code review ACK fa0d8359b351fd179a0a2f458671a4d7828c9a80 Tree-SHA512: d1e7e595d3b4a5e497ee7ab70f3be5783dafec2726ef8e012db836c15e8e622022859a4472d6b516fe19d327737b25fdfb509cd9aeb022ca847b13c54e55800a
This commit is contained in:
parent
c4b1c8b274
commit
058df132c4
@ -6,6 +6,8 @@
|
||||
#include <policy/fees.h>
|
||||
|
||||
#include <clientversion.h>
|
||||
#include <fs.h>
|
||||
#include <logging.h>
|
||||
#include <streams.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/system.h>
|
||||
@ -870,7 +872,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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -906,8 +908,9 @@ bool CBlockPolicyEstimator::Read(CAutoFile& filein)
|
||||
int nVersionRequired, nVersionThatWrote;
|
||||
unsigned int nFileBestSeenHeight;
|
||||
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.
|
||||
@ -924,8 +927,9 @@ bool CBlockPolicyEstimator::Read(CAutoFile& filein)
|
||||
std::vector<double> 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");
|
||||
}
|
||||
|
||||
auto fileFeeStats{std::make_unique<TxConfirmStats>(buckets, bucketMap, MED_BLOCK_PERIODS, MED_DECAY, MED_SCALE)};
|
||||
auto fileShortStats{std::make_unique<TxConfirmStats>(buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE)};
|
||||
|
Loading…
Reference in New Issue
Block a user