diff --git a/src/policy/mempool_fees.cpp b/src/policy/mempool_fees.cpp index 9054d7fe02ba70..87b028cb8c41fe 100644 --- a/src/policy/mempool_fees.cpp +++ b/src/policy/mempool_fees.cpp @@ -28,25 +28,23 @@ CFeeRate MemPoolPolicyEstimator::EstimateFeeWithMemPool(Chainstate& chainstate, err_message = "Mempool did not finish loading, can't get accurate fee rate estimate."; return CFeeRate(0); } - // Try the cache if not forced if (!force) { cached_fee = cache.get(confTarget); } if (!cached_fee) { - // Run block builder and update cache std::map mempool_fee_stats; - size_t target_weight = confTarget * DEFAULT_BLOCK_MAX_WEIGHT; - mempool_fee_stats = GetCustomBlockFeeRateHistogram(chainstate, &mempool, target_weight); + // Always get stats for MAX_CONF_TARGET blocks because current algo + // fast enough while we're here + mempool_fee_stats = GetCustomBlockFeeRateHistogram(chainstate, &mempool, DEFAULT_BLOCK_MAX_WEIGHT * MAX_CONF_TARGET); if (mempool_fee_stats.empty()) { err_message = "No transactions available in the mempool yet."; return CFeeRate(0); } - fee_rates = EstimateBlockFeeRatesWithMempool(mempool_fee_stats, confTarget); + fee_rates = EstimateBlockFeeRatesWithMempool(mempool_fee_stats, MAX_CONF_TARGET); cache.update(fee_rates); block_fee_rate = fee_rates[confTarget]; } else { - // Use the cached value block_fee_rate = *cached_fee; } @@ -60,7 +58,6 @@ std::map MemPoolPolicyEstimator::EstimateBlockFeeRatesWithMe const std::map& mempool_fee_stats, unsigned int confTarget) const { std::map fee_rates; - // Return empty if no stats if (mempool_fee_stats.empty()) return fee_rates; auto start = mempool_fee_stats.begin();