Skip to content

Commit 8b4ad20

Browse files
committed
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 <[email protected]> in bitcoin/bitcoin#19268 (comment)
1 parent e7a5bf6 commit 8b4ad20

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/policy/fees.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -998,13 +998,24 @@ void CBlockPolicyEstimator::FlushUnconfirmed() {
998998
LogPrint(BCLog::ESTIMATEFEE, "Recorded %u unconfirmed txs from mempool in %gs\n", num_entries, (endclear - startclear)*0.000001);
999999
}
10001000

1001-
FeeFilterRounder::FeeFilterRounder(const CFeeRate& minIncrementalFee)
1001+
static std::set<double> MakeFeeSet(const CFeeRate& minIncrementalFee,
1002+
double max_filter_fee_rate,
1003+
double fee_filter_spacing)
10021004
{
1003-
CAmount minFeeLimit = std::max(CAmount(1), minIncrementalFee.GetFeePerK() / 2);
1005+
std::set<double> feeset;
1006+
1007+
const CAmount minFeeLimit{std::max(CAmount(1), minIncrementalFee.GetFeePerK() / 2)};
10041008
feeset.insert(0);
1005-
for (double bucketBoundary = minFeeLimit; bucketBoundary <= MAX_FILTER_FEERATE; bucketBoundary *= FEE_FILTER_SPACING) {
1009+
for (double bucketBoundary = minFeeLimit; bucketBoundary <= max_filter_fee_rate; bucketBoundary *= fee_filter_spacing) {
10061010
feeset.insert(bucketBoundary);
10071011
}
1012+
1013+
return feeset;
1014+
}
1015+
1016+
FeeFilterRounder::FeeFilterRounder(const CFeeRate& minIncrementalFee)
1017+
: feeset{MakeFeeSet(minIncrementalFee, MAX_FILTER_FEERATE, FEE_FILTER_SPACING)}
1018+
{
10081019
}
10091020

10101021
CAmount FeeFilterRounder::round(CAmount currentMinFee)

src/policy/fees.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ class FeeFilterRounder
303303
CAmount round(CAmount currentMinFee);
304304

305305
private:
306-
std::set<double> feeset;
306+
const std::set<double> feeset;
307307
Mutex m_insecure_rand_mutex;
308308
FastRandomContext insecure_rand GUARDED_BY(m_insecure_rand_mutex);
309309
};

0 commit comments

Comments
 (0)