diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2022-02-21 17:11:59 +0100 |
---|---|---|
committer | Vasil Dimov <vd@FreeBSD.org> | 2022-04-18 10:40:06 +0200 |
commit | 8b4ad203d06c5ded6ecebbd7277b29a442d88bcf (patch) | |
tree | c2449923bb042e709afdde054dd11c3c68651bc5 /src/policy/fees.cpp | |
parent | e7a5bf6be79e341e037305a4c2d8a1a510a8d709 (diff) | |
download | bitcoin-8b4ad203d06c5ded6ecebbd7277b29a442d88bcf.tar.xz |
fees: make FeeFilterRounder::feeset const
It is only set in the constructor, thus improve readability by marking
it as `const` and setting it from the initializer list using a helper
function to derive its value.
The idea was suggested by Anthony Towns <aj@erisian.com.au> in
https://github.com/bitcoin/bitcoin/pull/19268#discussion_r439929792
Diffstat (limited to 'src/policy/fees.cpp')
-rw-r--r-- | src/policy/fees.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index 9f576e738a..d64360e82d 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -998,13 +998,24 @@ void CBlockPolicyEstimator::FlushUnconfirmed() { LogPrint(BCLog::ESTIMATEFEE, "Recorded %u unconfirmed txs from mempool in %gs\n", num_entries, (endclear - startclear)*0.000001); } -FeeFilterRounder::FeeFilterRounder(const CFeeRate& minIncrementalFee) +static std::set<double> MakeFeeSet(const CFeeRate& minIncrementalFee, + double max_filter_fee_rate, + double fee_filter_spacing) { - CAmount minFeeLimit = std::max(CAmount(1), minIncrementalFee.GetFeePerK() / 2); + std::set<double> feeset; + + const CAmount minFeeLimit{std::max(CAmount(1), minIncrementalFee.GetFeePerK() / 2)}; feeset.insert(0); - for (double bucketBoundary = minFeeLimit; bucketBoundary <= MAX_FILTER_FEERATE; bucketBoundary *= FEE_FILTER_SPACING) { + for (double bucketBoundary = minFeeLimit; bucketBoundary <= max_filter_fee_rate; bucketBoundary *= fee_filter_spacing) { feeset.insert(bucketBoundary); } + + return feeset; +} + +FeeFilterRounder::FeeFilterRounder(const CFeeRate& minIncrementalFee) + : feeset{MakeFeeSet(minIncrementalFee, MAX_FILTER_FEERATE, FEE_FILTER_SPACING)} +{ } CAmount FeeFilterRounder::round(CAmount currentMinFee) |