diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 1ecc59904..fe8e68fd1 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -890,7 +890,7 @@ CTxMemPool::WriteFeeEstimates(CAutoFile& fileout) const { try { LOCK(cs); - fileout << 139900; // version required to read: 0.13.99 or later + fileout << FEEFILE_MIN_BACKCOMPAT_VERSION; fileout << CLIENT_VERSION; // version that wrote the file minerPolicyEstimator->Write(fileout); } @@ -909,6 +909,16 @@ CTxMemPool::ReadFeeEstimates(CAutoFile& filein) filein >> nVersionRequired >> nVersionThatWrote; if (nVersionRequired > CLIENT_VERSION) return error("CTxMemPool::ReadFeeEstimates(): up-version (%d) fee estimate file", nVersionRequired); + + /* From 1.14.7, only accept fee estimate files created by a version equal to or higher than the + * minimum writer version. + * + * If in the future any of the MIN_FEERATE, MAX_FEERATE or FEE_SPACING in policy/fees.h change, + * or these values become configurable, this logic will need to be adapted. */ + if (nVersionThatWrote < FEEFILE_MIN_COMPAT_VERSION_WRITER) { + return error("CTxMemPool::ReadFeeEstimates(): cannot re-use fee estimate files from version %d, ignoring file (non-fatal)", nVersionThatWrote); + } + LOCK(cs); minerPolicyEstimator->Read(filein, nVersionThatWrote); } diff --git a/src/txmempool.h b/src/txmempool.h index 28510dabd..a0251f1e3 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -31,6 +31,19 @@ class CAutoFile; class CBlockIndex; +/** Minimum client version required to read fee_estimates.dat + * Clients with a lower version than this should ignore the file + */ +static const int FEEFILE_MIN_BACKCOMPAT_VERSION = 1140700; // 1.14.7.0 + +/** Minimum client version required to read fee_estimates.dat + * Files created with a lower version than this are ignored + * + * Due to bucket spacing and min/max changes in 1.14.7, set this + * to 1.14.7.0 exactly. + */ +static const int FEEFILE_MIN_COMPAT_VERSION_WRITER = 1140700; // 1.14.7.0 + inline double AllowFreeThreshold() { return COIN * 144 / 250;