diff options
-rw-r--r-- | src/policy/fees.cpp | 25 | ||||
-rw-r--r-- | src/policy/fees.h | 4 |
2 files changed, 16 insertions, 13 deletions
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index d64360e82d..44024ce7ac 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -998,31 +998,34 @@ void CBlockPolicyEstimator::FlushUnconfirmed() { LogPrint(BCLog::ESTIMATEFEE, "Recorded %u unconfirmed txs from mempool in %gs\n", num_entries, (endclear - startclear)*0.000001); } -static std::set<double> MakeFeeSet(const CFeeRate& minIncrementalFee, +static std::set<double> MakeFeeSet(const CFeeRate& min_incremental_fee, double max_filter_fee_rate, double fee_filter_spacing) { - std::set<double> feeset; + std::set<double> fee_set; - const CAmount minFeeLimit{std::max(CAmount(1), minIncrementalFee.GetFeePerK() / 2)}; - feeset.insert(0); - for (double bucketBoundary = minFeeLimit; bucketBoundary <= max_filter_fee_rate; bucketBoundary *= fee_filter_spacing) { - feeset.insert(bucketBoundary); + const CAmount min_fee_limit{std::max(CAmount(1), min_incremental_fee.GetFeePerK() / 2)}; + fee_set.insert(0); + for (double bucket_boundary = min_fee_limit; + bucket_boundary <= max_filter_fee_rate; + bucket_boundary *= fee_filter_spacing) { + + fee_set.insert(bucket_boundary); } - return feeset; + return fee_set; } FeeFilterRounder::FeeFilterRounder(const CFeeRate& minIncrementalFee) - : feeset{MakeFeeSet(minIncrementalFee, MAX_FILTER_FEERATE, FEE_FILTER_SPACING)} + : m_fee_set{MakeFeeSet(minIncrementalFee, MAX_FILTER_FEERATE, FEE_FILTER_SPACING)} { } CAmount FeeFilterRounder::round(CAmount currentMinFee) { - std::set<double>::iterator it = feeset.lower_bound(currentMinFee); - if (it == feeset.end() || - (it != feeset.begin() && + std::set<double>::iterator it = m_fee_set.lower_bound(currentMinFee); + if (it == m_fee_set.end() || + (it != m_fee_set.begin() && WITH_LOCK(m_insecure_rand_mutex, return insecure_rand.rand32()) % 3 != 0)) { --it; } diff --git a/src/policy/fees.h b/src/policy/fees.h index e7f45c3151..b44ba4dc7a 100644 --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -297,13 +297,13 @@ private: public: /** Create new FeeFilterRounder */ - explicit FeeFilterRounder(const CFeeRate& minIncrementalFee); + explicit FeeFilterRounder(const CFeeRate& min_incremental_fee); /** Quantize a minimum fee for privacy purpose before broadcast. */ CAmount round(CAmount currentMinFee); private: - const std::set<double> feeset; + const std::set<double> m_fee_set; Mutex m_insecure_rand_mutex; FastRandomContext insecure_rand GUARDED_BY(m_insecure_rand_mutex); }; |