5#ifndef BITCOIN_POLICY_FEES_MEMPOOL_ESTIMATOR_H
6#define BITCOIN_POLICY_FEES_MEMPOOL_ESTIMATOR_H
118 return m_prev_mined_blocks;
122 const std::vector<RemovedMempoolTransactionInfo>& txs_removed_for_block,
123 unsigned int block_height)
Non-refcounted RAII wrapper for FILE*.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Interface for managing multiple Chainstate objects, where each chainstate is associated with chainsta...
MemPoolFeeRateEstimatorCache holds a cache of recent fee rate estimates.
MemPoolFeeRateEstimatorCache()=default
std::optional< FeeRateEstimate > GetCachedEstimate(const uint256 &tip_hash) const
Returns cached estimates if not stale and computed on tip_hash, nullopt otherwise.
NodeClock::time_point m_last_updated
MemPoolFeeRateEstimatorCache(const MemPoolFeeRateEstimatorCache &)=delete
void Clear()
Clear cached fee rate estimates.
bool IsStale() const
Returns true if the cache is empty or older than CACHE_LIFE.
std::optional< FeeRateEstimate > m_fee_rate_estimation
MemPoolFeeRateEstimatorCache & operator=(const MemPoolFeeRateEstimatorCache &)=delete
void Update(FeePerVSize conservative, FeePerVSize economical, const uint256 &tip_hash)
Update the cache with new estimates computed on tip_hash.
Estimate the fee rate required for a transaction to be included in the next block.
~MemPoolFeeRateEstimator()=default
void ReadFromDisk() EXCLUSIVE_LOCKS_REQUIRED(!cs)
std::vector< MinedBlockStats > m_prev_mined_blocks GUARDED_BY(cs)
Tracks weight statistics for the last MEMPOOL_HEALTH_WINDOW_BLOCKS mined blocks.
bool Write(AutoFile &file) const EXCLUSIVE_LOCKS_REQUIRED(!cs)
Serialize mined-block stats without taking ownership of file.
MempoolHealth GetMempoolHealth() const EXCLUSIVE_LOCKS_REQUIRED(!cs)
const CTxMemPool & m_mempool
ChainstateManager & m_chainman
unsigned int MaximumTarget() const
bool IsMempoolHealthy() const EXCLUSIVE_LOCKS_REQUIRED(!cs)
Checks if recent mined blocks indicate a healthy mempool state.
void MempoolTxsRemovedForBlock(const std::shared_ptr< const CBlock > &block, const std::vector< RemovedMempoolTransactionInfo > &txs_removed_for_block, unsigned int block_height) EXCLUSIVE_LOCKS_REQUIRED(!cs)
void FlushMinedBlockStats() EXCLUSIVE_LOCKS_REQUIRED(!cs)
static Percentiles CalculateMaxWeightPercentiles(std::span< const FeePerVSize > chunk_feerates)
Calculate the 50th and 75th percentile fee rates from block template chunks, sorted in descending min...
const fs::path m_mempool_estimator_file_path
std::vector< MinedBlockStats > GetPrevBlockData() const EXCLUSIVE_LOCKS_REQUIRED(!cs)
bool Read(AutoFile &file) EXCLUSIVE_LOCKS_REQUIRED(!cs)
Deserialize mined-block stats without taking ownership of file.
util::Expected< FeeRateEstimation, FeeRateEstimationError > EstimateFeeRate(bool conservative) const EXCLUSIVE_LOCKS_REQUIRED(!cs)
MemPoolFeeRateEstimator(fs::path mempool_estimator_file_path, const CTxMemPool &mempool, ChainstateManager &chainman)
MempoolHealth
Health of the recent mined-block window for fee rate estimation.
@ HEALTHY
Recent blocks represent the mempool well enough to estimate a fee rate.
The util::Expected class provides a standard way for low-level functions to return either error value...
constexpr int MEMPOOL_FEE_ESTIMATOR_MAX_TARGET
constexpr std::chrono::seconds CACHE_LIFE
constexpr double MEMPOOL_REPRESENTATION_THRESHOLD
constexpr size_t MEMPOOL_HEALTH_WINDOW_BLOCKS
FeePerVSize m_conservative
Weight statistics for a recently mined block, used to assess mempool coverage.
uint64_t m_block_weight
Total non-coinbase transaction weight in the block.
uint64_t m_height
Block height.
uint64_t m_removed_block_txs_weight
Weight of mempool transactions removed for this block (excluding coinbase).
std::chrono::time_point< NodeClock > time_point
#define EXCLUSIVE_LOCKS_REQUIRED(...)