From c36869bbf6a38626833b4aea53be024c48ede475 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Fri, 31 Jul 2020 20:28:40 +0200 Subject: policy/fees: unify some duplicated for loops Signed-off-by: Antoine Poinsot --- src/policy/fees.cpp | 13 ++++++------- 1 file 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& 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; } -- cgit v1.2.3