mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge d94adc7270 into merged_master (Bitcoin PR bitcoin/bitcoin#29702)
This commit is contained in:
commit
d4d930fac7
1 changed files with 22 additions and 21 deletions
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include <policy/fees.h>
|
||||
|
||||
#include <clientversion.h>
|
||||
#include <common/system.h>
|
||||
#include <consensus/amount.h>
|
||||
#include <kernel/mempool_entry.h>
|
||||
|
|
@ -32,6 +31,10 @@
|
|||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
// The current format written, and the version required to read. Must be
|
||||
// increased to at least 289900+1 on the next breaking change.
|
||||
constexpr int CURRENT_FEES_FILE_VERSION{149900};
|
||||
|
||||
static constexpr double INF_FEERATE = 1e99;
|
||||
|
||||
std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon)
|
||||
|
|
@ -168,7 +171,7 @@ public:
|
|||
* Read saved state of estimation data from a file and replace all internal data structures and
|
||||
* variables with this state.
|
||||
*/
|
||||
void Read(AutoFile& filein, int nFileVersion, size_t numBuckets);
|
||||
void Read(AutoFile& filein, size_t numBuckets);
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -414,7 +417,7 @@ void TxConfirmStats::Write(AutoFile& fileout) const
|
|||
fileout << Using<VectorFormatter<VectorFormatter<EncodedDoubleFormatter>>>(failAvg);
|
||||
}
|
||||
|
||||
void TxConfirmStats::Read(AutoFile& filein, int nFileVersion, size_t numBuckets)
|
||||
void TxConfirmStats::Read(AutoFile& filein, size_t numBuckets)
|
||||
{
|
||||
// Read data file and do some very basic sanity checking
|
||||
// buckets and bucketMap are not updated yet, so don't access them
|
||||
|
|
@ -961,10 +964,8 @@ bool CBlockPolicyEstimator::Write(AutoFile& fileout) const
|
|||
{
|
||||
try {
|
||||
LOCK(m_cs_fee_estimator);
|
||||
//ELEMENTS: We upped this from 0.14.99 in upstream because
|
||||
// we changed the bucket sizes.
|
||||
fileout << 180107; // version required to read: 0.18.1.7
|
||||
fileout << CLIENT_VERSION; // version that wrote the file
|
||||
fileout << CURRENT_FEES_FILE_VERSION;
|
||||
fileout << int{0}; // Unused dummy field. Written files may contain any value in [0, 289900]
|
||||
fileout << nBestSeenHeight;
|
||||
if (BlockSpan() > HistoricalBlockSpan()/2) {
|
||||
fileout << firstRecordedHeight << nBestSeenHeight;
|
||||
|
|
@ -978,7 +979,7 @@ bool CBlockPolicyEstimator::Write(AutoFile& fileout) const
|
|||
longStats->Write(fileout);
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
LogPrintf("CBlockPolicyEstimator::Write(): unable to write policy estimator data (non-fatal)\n");
|
||||
LogWarning("Unable to write policy estimator data (non-fatal)");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -988,10 +989,10 @@ bool CBlockPolicyEstimator::Read(AutoFile& filein)
|
|||
{
|
||||
try {
|
||||
LOCK(m_cs_fee_estimator);
|
||||
int nVersionRequired, nVersionThatWrote;
|
||||
filein >> nVersionRequired >> nVersionThatWrote;
|
||||
if (nVersionRequired > CLIENT_VERSION) {
|
||||
throw std::runtime_error(strprintf("up-version (%d) fee estimate file", nVersionRequired));
|
||||
int nVersionRequired, dummy;
|
||||
filein >> nVersionRequired >> dummy;
|
||||
if (nVersionRequired > CURRENT_FEES_FILE_VERSION) {
|
||||
throw std::runtime_error{strprintf("File version (%d) too high to be read.", nVersionRequired)};
|
||||
}
|
||||
|
||||
// Read fee estimates file into temporary variables so existing data
|
||||
|
|
@ -999,12 +1000,12 @@ bool CBlockPolicyEstimator::Read(AutoFile& filein)
|
|||
unsigned int nFileBestSeenHeight;
|
||||
filein >> nFileBestSeenHeight;
|
||||
|
||||
if (nVersionRequired < 149900) {
|
||||
LogPrintf("%s: incompatible old fee estimation data (non-fatal). Version: %d\n", __func__, nVersionRequired);
|
||||
} else if (nVersionThatWrote < 180107) {
|
||||
if (nVersionRequired < CURRENT_FEES_FILE_VERSION) {
|
||||
LogWarning("Incompatible old fee estimation data (non-fatal). Version: %d", nVersionRequired);
|
||||
} else if (nVersionRequired < 180107) {
|
||||
//ELEMENTS: we changed the buckets in 0.18.1.7
|
||||
LogPrintf("%s: incompatible old fee estimation data (non-fatal). Version: %d\n", __func__, nVersionThatWrote);
|
||||
} else { // New format introduced in 149900
|
||||
LogPrintf("%s: incompatible old fee estimation data (non-fatal). Version: %d\n", __func__, nVersionRequired);
|
||||
} else { // nVersionRequired == CURRENT_FEES_FILE_VERSION
|
||||
unsigned int nFileHistoricalFirst, nFileHistoricalBest;
|
||||
filein >> nFileHistoricalFirst >> nFileHistoricalBest;
|
||||
if (nFileHistoricalFirst > nFileHistoricalBest || nFileHistoricalBest > nFileBestSeenHeight) {
|
||||
|
|
@ -1020,9 +1021,9 @@ bool CBlockPolicyEstimator::Read(AutoFile& filein)
|
|||
std::unique_ptr<TxConfirmStats> fileFeeStats(new TxConfirmStats(buckets, bucketMap, MED_BLOCK_PERIODS, MED_DECAY, MED_SCALE));
|
||||
std::unique_ptr<TxConfirmStats> fileShortStats(new TxConfirmStats(buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE));
|
||||
std::unique_ptr<TxConfirmStats> fileLongStats(new TxConfirmStats(buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE));
|
||||
fileFeeStats->Read(filein, nVersionThatWrote, numBuckets);
|
||||
fileShortStats->Read(filein, nVersionThatWrote, numBuckets);
|
||||
fileLongStats->Read(filein, nVersionThatWrote, numBuckets);
|
||||
fileFeeStats->Read(filein, numBuckets);
|
||||
fileShortStats->Read(filein, numBuckets);
|
||||
fileLongStats->Read(filein, numBuckets);
|
||||
|
||||
// Fee estimates file parsed correctly
|
||||
// Copy buckets from file and refresh our bucketmap
|
||||
|
|
@ -1043,7 +1044,7 @@ bool CBlockPolicyEstimator::Read(AutoFile& filein)
|
|||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
LogPrintf("CBlockPolicyEstimator::Read(): unable to read policy estimator data (non-fatal): %s\n",e.what());
|
||||
LogWarning("Unable to read policy estimator data (non-fatal): %s", e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue