mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
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
This commit is contained in:
parent
e7a5bf6be7
commit
8b4ad203d0
2 changed files with 15 additions and 4 deletions
|
@ -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);
|
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);
|
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);
|
feeset.insert(bucketBoundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return feeset;
|
||||||
|
}
|
||||||
|
|
||||||
|
FeeFilterRounder::FeeFilterRounder(const CFeeRate& minIncrementalFee)
|
||||||
|
: feeset{MakeFeeSet(minIncrementalFee, MAX_FILTER_FEERATE, FEE_FILTER_SPACING)}
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CAmount FeeFilterRounder::round(CAmount currentMinFee)
|
CAmount FeeFilterRounder::round(CAmount currentMinFee)
|
||||||
|
|
|
@ -303,7 +303,7 @@ public:
|
||||||
CAmount round(CAmount currentMinFee);
|
CAmount round(CAmount currentMinFee);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::set<double> feeset;
|
const std::set<double> feeset;
|
||||||
Mutex m_insecure_rand_mutex;
|
Mutex m_insecure_rand_mutex;
|
||||||
FastRandomContext insecure_rand GUARDED_BY(m_insecure_rand_mutex);
|
FastRandomContext insecure_rand GUARDED_BY(m_insecure_rand_mutex);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue