![]() |
Bitcoin Core 31.99.0
P2P Digital Currency
|
Estimate the fee rate required for a transaction to be included in the next block. More...
#include <mempool_estimator.h>
Classes | |
| struct | Percentiles |
Public Types | |
| enum class | MempoolHealth { HEALTHY , INSUFFICIENT_DATA , LOW_COVERAGE } |
| Health of the recent mined-block window for fee rate estimation. More... | |
Public Member Functions | |
| MemPoolFeeRateEstimator (fs::path mempool_estimator_file_path, const CTxMemPool &mempool, ChainstateManager &chainman) | |
| ~MemPoolFeeRateEstimator ()=default | |
| util::Expected< FeeRateEstimation, FeeRateEstimationError > | EstimateFeeRate (bool conservative) const EXCLUSIVE_LOCKS_REQUIRED(!cs) |
| unsigned int | MaximumTarget () const |
| std::vector< MinedBlockStats > | GetPrevBlockData () const EXCLUSIVE_LOCKS_REQUIRED(!cs) |
| 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) |
| MempoolHealth | GetMempoolHealth () const EXCLUSIVE_LOCKS_REQUIRED(!cs) |
| bool | IsMempoolHealthy () const EXCLUSIVE_LOCKS_REQUIRED(!cs) |
| Checks if recent mined blocks indicate a healthy mempool state. More... | |
| void | FlushMinedBlockStats () EXCLUSIVE_LOCKS_REQUIRED(!cs) |
| bool | Read (AutoFile &file) EXCLUSIVE_LOCKS_REQUIRED(!cs) |
| Deserialize mined-block stats without taking ownership of file. More... | |
| bool | Write (AutoFile &file) const EXCLUSIVE_LOCKS_REQUIRED(!cs) |
| Serialize mined-block stats without taking ownership of file. More... | |
Static Public Member Functions | |
| static Percentiles | CalculateMaxWeightPercentiles (std::span< const FeePerVSize > chunk_feerates) |
| Calculate the 50th and 75th percentile fee rates from block template chunks, sorted in descending mining-score order. More... | |
Private Member Functions | |
| 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. More... | |
| uint256 m_mined_blocks_tip_hash | GUARDED_BY (cs) |
| MemPoolFeeRateEstimatorCache m_cache | GUARDED_BY (cs) |
Private Attributes | |
| const CTxMemPool & | m_mempool |
| ChainstateManager & | m_chainman |
| Mutex | cs |
| const fs::path | m_mempool_estimator_file_path |
Estimate the fee rate required for a transaction to be included in the next block.
Uses Bitcoin Core's block-building algorithm to generate a block template from the mempool, then calculates percentile fee rates from the selected chunks: the 75th percentile is returned as the economical estimate and the 50th percentile as the conservative estimate.
Definition at line 87 of file mempool_estimator.h.
|
strong |
Health of the recent mined-block window for fee rate estimation.
Definition at line 126 of file mempool_estimator.h.
| MemPoolFeeRateEstimator::MemPoolFeeRateEstimator | ( | fs::path | mempool_estimator_file_path, |
| const CTxMemPool & | mempool, | ||
| ChainstateManager & | chainman | ||
| ) |
|
default |
|
static |
Calculate the 50th and 75th percentile fee rates from block template chunks, sorted in descending mining-score order.
A percentile is left empty when the chunks cannot cover the corresponding fraction of a block.
| [in] | chunk_feerates | Block template chunk fee rates sorted by descending mining score. |
Definition at line 95 of file mempool_estimator.cpp.
| util::Expected< FeeRateEstimation, FeeRateEstimationError > MemPoolFeeRateEstimator::EstimateFeeRate | ( | bool | conservative | ) | const |
| void MemPoolFeeRateEstimator::FlushMinedBlockStats | ( | ) |
| MemPoolFeeRateEstimator::MempoolHealth MemPoolFeeRateEstimator::GetMempoolHealth | ( | ) | const |
Definition at line 323 of file mempool_estimator.cpp.
|
inline |
Definition at line 115 of file mempool_estimator.h.
|
private |
Tracks weight statistics for the last MEMPOOL_HEALTH_WINDOW_BLOCKS mined blocks.
|
mutableprivate |
|
inline |
Checks if recent mined blocks indicate a healthy mempool state.
Definition at line 136 of file mempool_estimator.h.
|
inline |
Definition at line 110 of file mempool_estimator.h.
| void MemPoolFeeRateEstimator::MempoolTxsRemovedForBlock | ( | const std::shared_ptr< const CBlock > & | block, |
| const std::vector< RemovedMempoolTransactionInfo > & | txs_removed_for_block, | ||
| unsigned int | block_height | ||
| ) |
Definition at line 294 of file mempool_estimator.cpp.
| bool MemPoolFeeRateEstimator::Read | ( | AutoFile & | file | ) |
Deserialize mined-block stats without taking ownership of file.
Definition at line 188 of file mempool_estimator.cpp.
|
private |
Definition at line 172 of file mempool_estimator.cpp.
| bool MemPoolFeeRateEstimator::Write | ( | AutoFile & | file | ) | const |
Serialize mined-block stats without taking ownership of file.
Callers must explicitly close file and check for errors after writing.
Definition at line 246 of file mempool_estimator.cpp.
|
mutableprivate |
Definition at line 152 of file mempool_estimator.h.
|
private |
Definition at line 151 of file mempool_estimator.h.
|
private |
Definition at line 150 of file mempool_estimator.h.
|
private |
Definition at line 154 of file mempool_estimator.h.