aboutsummaryrefslogtreecommitdiff
path: root/src/policy
diff options
context:
space:
mode:
authorismaelsadeeq <ask4ismailsadiq@gmail.com>2023-06-14 22:39:26 +0100
committerismaelsadeeq <ask4ismailsadiq@gmail.com>2023-06-14 22:39:26 +0100
commitcf219f29f3c5b41070eaab9a549a476f01990f3a (patch)
treeac5367737ca406fcb404261118542cd5565a315a /src/policy
parent3eb241a141defa564c94cb95c5bbaf4c5bd9682e (diff)
downloadbitcoin-cf219f29f3c5b41070eaab9a549a476f01990f3a.tar.xz
tx fees, policy: read stale fee estimates with a regtest-only option
If -acceptstalefeeestimates option is passed stale fee estimates can now be read when operating in regtest environments. Additionally, this commit updates all declarations of the CBlockPolicyEstimator class to include a the second constructor variable.
Diffstat (limited to 'src/policy')
-rw-r--r--src/policy/fees.cpp4
-rw-r--r--src/policy/fees.h5
2 files changed, 6 insertions, 3 deletions
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp
index a8ca8545d3..c8f2df781b 100644
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -528,7 +528,7 @@ bool CBlockPolicyEstimator::_removeTx(const uint256& hash, bool inBlock)
}
}
-CBlockPolicyEstimator::CBlockPolicyEstimator(const fs::path& estimation_filepath)
+CBlockPolicyEstimator::CBlockPolicyEstimator(const fs::path& estimation_filepath, const bool read_stale_estimates)
: m_estimation_filepath{estimation_filepath}
{
static_assert(MIN_BUCKET_FEERATE > 0, "Min feerate must be nonzero");
@@ -556,7 +556,7 @@ CBlockPolicyEstimator::CBlockPolicyEstimator(const fs::path& estimation_filepath
std::chrono::hours file_age = GetFeeEstimatorFileAge();
// fee estimate file must not be too old to avoid wrong fee estimates.
- if (file_age > MAX_FILE_AGE) {
+ if (file_age > MAX_FILE_AGE && !read_stale_estimates) {
LogPrintf("Fee estimation file %s too old (age=%lld > %lld hours) and will not be used to avoid serving stale estimates.\n", fs::PathToString(m_estimation_filepath), Ticks<std::chrono::hours>(file_age), Ticks<std::chrono::hours>(MAX_FILE_AGE));
return;
}
diff --git a/src/policy/fees.h b/src/policy/fees.h
index a348ba05d8..52761f03ca 100644
--- a/src/policy/fees.h
+++ b/src/policy/fees.h
@@ -30,6 +30,9 @@ static constexpr std::chrono::hours FEE_FLUSH_INTERVAL{1};
*/
static constexpr std::chrono::hours MAX_FILE_AGE{60};
+// Whether we allow importing a fee_estimates file older than MAX_FILE_AGE.
+static constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES{false};
+
class AutoFile;
class CTxMemPoolEntry;
class TxConfirmStats;
@@ -193,7 +196,7 @@ private:
const fs::path m_estimation_filepath;
public:
/** Create new BlockPolicyEstimator and initialize stats tracking classes with default values */
- CBlockPolicyEstimator(const fs::path& estimation_filepath);
+ CBlockPolicyEstimator(const fs::path& estimation_filepath, const bool read_stale_estimates);
~CBlockPolicyEstimator();
/** Process all the transactions that have been included in a block */