Skip to content

Commit cdd6bbf

Browse files
committed
Merge #11273: Ignore old format estimation file
3a3a9f9 Ignore old format estimation file (Murch) Pull request description: The fee estimation data format changed from 0.14.x to 0.15.0, so we should no longer read the old data. H/T @jnewbery, @morcos Pending testing. Tree-SHA512: c8e3824dbdd8f6730133d5ad20b00995e9a63ab54431158a91e2f4d2aba5763b8aa698bce1fffca2713ba3a162e23d8fcd6e3efb9847b015c2e1e8725398150b
2 parents 81c89e9 + 3a3a9f9 commit cdd6bbf

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

src/policy/fees.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -944,32 +944,9 @@ bool CBlockPolicyEstimator::Read(CAutoFile& filein)
944944
unsigned int nFileBestSeenHeight;
945945
filein >> nFileBestSeenHeight;
946946

947-
if (nVersionThatWrote < 149900) {
948-
// Read the old fee estimates file for temporary use, but then discard. Will start collecting data from scratch.
949-
// decay is stored before buckets in old versions, so pre-read decay and pass into TxConfirmStats constructor
950-
double tempDecay;
951-
filein >> tempDecay;
952-
if (tempDecay <= 0 || tempDecay >= 1)
953-
throw std::runtime_error("Corrupt estimates file. Decay must be between 0 and 1 (non-inclusive)");
954-
955-
std::vector<double> tempBuckets;
956-
filein >> tempBuckets;
957-
size_t tempNum = tempBuckets.size();
958-
if (tempNum <= 1 || tempNum > 1000)
959-
throw std::runtime_error("Corrupt estimates file. Must have between 2 and 1000 feerate buckets");
960-
961-
std::map<double, unsigned int> tempMap;
962-
963-
std::unique_ptr<TxConfirmStats> tempFeeStats(new TxConfirmStats(tempBuckets, tempMap, MED_BLOCK_PERIODS, tempDecay, 1));
964-
tempFeeStats->Read(filein, nVersionThatWrote, tempNum);
965-
// if nVersionThatWrote < 139900 then another TxConfirmStats (for priority) follows but can be ignored.
966-
967-
tempMap.clear();
968-
for (unsigned int i = 0; i < tempBuckets.size(); i++) {
969-
tempMap[tempBuckets[i]] = i;
970-
}
971-
}
972-
else { // nVersionThatWrote >= 149900
947+
if (nVersionRequired < 149900) {
948+
LogPrintf("%s: incompatible old fee estimation data (non-fatal). Version: %d\n", __func__, nVersionRequired);
949+
} else { // New format introduced in 149900
973950
unsigned int nFileHistoricalFirst, nFileHistoricalBest;
974951
filein >> nFileHistoricalFirst >> nFileHistoricalBest;
975952
if (nFileHistoricalFirst > nFileHistoricalBest || nFileHistoricalBest > nFileBestSeenHeight) {

0 commit comments

Comments
 (0)