aboutsummaryrefslogtreecommitdiff
path: root/src/policy/fees.cpp
diff options
context:
space:
mode:
authorAntoine Poinsot <darosior@protonmail.com>2020-07-31 20:28:40 +0200
committerAntoine Poinsot <darosior@protonmail.com>2020-09-14 15:28:27 +0200
commitc36869bbf6a38626833b4aea53be024c48ede475 (patch)
tree8de51638a7b37b1f01eccbf084746a4943c9e48e /src/policy/fees.cpp
parent569d92a4d2924a1f6d50775980b591552f6372e7 (diff)
policy/fees: unify some duplicated for loops
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
Diffstat (limited to 'src/policy/fees.cpp')
-rw-r--r--src/policy/fees.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp
index 7820d00fd6..47ff4a9cbf 100644
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -141,11 +141,9 @@ TxConfirmStats::TxConfirmStats(const std::vector<double>& defaultBuckets,
{
assert(_scale != 0 && "_scale must be non-zero");
confAvg.resize(maxPeriods);
- for (unsigned int i = 0; i < maxPeriods; i++) {
- confAvg[i].resize(buckets.size());
- }
failAvg.resize(maxPeriods);
for (unsigned int i = 0; i < maxPeriods; i++) {
+ confAvg[i].resize(buckets.size());
failAvg[i].resize(buckets.size());
}
@@ -190,11 +188,12 @@ void TxConfirmStats::Record(int blocksToConfirm, double feerate)
void TxConfirmStats::UpdateMovingAverages()
{
+ assert(confAvg.size() == failAvg.size());
for (unsigned int j = 0; j < buckets.size(); j++) {
- for (unsigned int i = 0; i < confAvg.size(); i++)
- confAvg[i][j] = confAvg[i][j] * decay;
- for (unsigned int i = 0; i < failAvg.size(); i++)
- failAvg[i][j] = failAvg[i][j] * decay;
+ for (unsigned int i = 0; i < confAvg.size(); i++) {
+ confAvg[i][j] *= decay;
+ failAvg[i][j] *= decay;
+ }
m_feerate_avg[j] *= decay;
txCtAvg[j] *= decay;
}