From 3eb241a141defa564c94cb95c5bbaf4c5bd9682e Mon Sep 17 00:00:00 2001 From: ismaelsadeeq Date: Wed, 14 Jun 2023 22:32:27 +0100 Subject: tx fees, policy: do not read estimates of old fee_estimates.dat Old fee estimates could cause transactions to become stuck in the mempool. This commit prevents the node from using stale estimates from an old file. --- src/policy/fees.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/policy/fees.h') diff --git a/src/policy/fees.h b/src/policy/fees.h index a6c45839b9..a348ba05d8 100644 --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -25,6 +25,11 @@ // How often to flush fee estimates to fee_estimates.dat. static constexpr std::chrono::hours FEE_FLUSH_INTERVAL{1}; +/** fee_estimates.dat that are more than 60 hours (2.5 days) will not be read, + * as the estimates in the file are stale. + */ +static constexpr std::chrono::hours MAX_FILE_AGE{60}; + class AutoFile; class CTxMemPoolEntry; class TxConfirmStats; @@ -248,6 +253,9 @@ public: void FlushFeeEstimates() EXCLUSIVE_LOCKS_REQUIRED(!m_cs_fee_estimator); + /** Calculates the age of the file, since last modified */ + std::chrono::hours GetFeeEstimatorFileAge(); + private: mutable Mutex m_cs_fee_estimator; -- cgit v1.2.3