Skip to content

Commit

Permalink
policy/fees: unify some duplicated for loops
Browse files Browse the repository at this point in the history
Signed-off-by: Antoine Poinsot <[email protected]>
  • Loading branch information
darosior committed Sep 14, 2020
1 parent 569d92a commit c36869b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/policy/fees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit c36869b

Please sign in to comment.