From ddddbac9c10ba80c94e1f3ceeffa7091d18ea48d Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 22 Mar 2024 10:03:42 +0100 Subject: [PATCH] fees: Pin required version to 149900 There is no need to compare the field to CLIENT_VERSION. Either the format remains compatible and the value can be left unchanged, or it is incompatible and the value needs to be increased to at least 289900+1. --- src/policy/fees.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index dff378c321f..143a3d6171f 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -5,7 +5,6 @@ #include -#include #include #include #include @@ -32,6 +31,10 @@ #include #include +// 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) @@ -961,7 +964,7 @@ bool CBlockPolicyEstimator::Write(AutoFile& fileout) const { try { LOCK(m_cs_fee_estimator); - fileout << 149900; // version required to read: 0.14.99 or later + 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) { @@ -988,7 +991,7 @@ bool CBlockPolicyEstimator::Read(AutoFile& filein) LOCK(m_cs_fee_estimator); int nVersionRequired, dummy; filein >> nVersionRequired >> dummy; - if (nVersionRequired > CLIENT_VERSION) { + if (nVersionRequired > CURRENT_FEES_FILE_VERSION) { throw std::runtime_error(strprintf("up-version (%d) fee estimate file", nVersionRequired)); } @@ -997,9 +1000,9 @@ bool CBlockPolicyEstimator::Read(AutoFile& filein) unsigned int nFileBestSeenHeight; filein >> nFileBestSeenHeight; - if (nVersionRequired < 149900) { + if (nVersionRequired < CURRENT_FEES_FILE_VERSION) { LogPrintf("%s: incompatible old fee estimation data (non-fatal). Version: %d\n", __func__, nVersionRequired); - } else { // New format introduced in 149900 + } else { // nVersionRequired == CURRENT_FEES_FILE_VERSION unsigned int nFileHistoricalFirst, nFileHistoricalBest; filein >> nFileHistoricalFirst >> nFileHistoricalBest; if (nFileHistoricalFirst > nFileHistoricalBest || nFileHistoricalBest > nFileBestSeenHeight) {