aboutsummaryrefslogtreecommitdiff
path: root/src/policy/fees.cpp
diff options
context:
space:
mode:
authorAntoine Poinsot <darosior@protonmail.com>2020-08-15 01:57:59 +0200
committerAntoine Poinsot <darosior@protonmail.com>2020-09-14 16:23:23 +0200
commita3abeec33a6ae903e514c7a7b6f587b7c17288a0 (patch)
treed6963db7510ef0780138b9432c61670d17043d99 /src/policy/fees.cpp
parentc36869bbf6a38626833b4aea53be024c48ede475 (diff)
policy/fees: remove a floating-point division by zero
Reported-by: practicalswift <practicalswift@users.noreply.github.com> 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, 11 insertions, 2 deletions
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp
index 47ff4a9cbf..0f31093dbb 100644
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -325,13 +325,22 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal,
failBucket.leftMempool = failNum;
}
+ float passed_within_target_perc = 0.0;
+ float failed_within_target_perc = 0.0;
+ if ((passBucket.totalConfirmed + passBucket.inMempool + passBucket.leftMempool)) {
+ passed_within_target_perc = 100 * passBucket.withinTarget / (passBucket.totalConfirmed + passBucket.inMempool + passBucket.leftMempool);
+ }
+ if ((failBucket.totalConfirmed + failBucket.inMempool + failBucket.leftMempool)) {
+ failed_within_target_perc = 100 * failBucket.withinTarget / (failBucket.totalConfirmed + failBucket.inMempool + failBucket.leftMempool);
+ }
+
LogPrint(BCLog::ESTIMATEFEE, "FeeEst: %d > %.0f%% decay %.5f: feerate: %g from (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out) Fail: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out)\n",
confTarget, 100.0 * successBreakPoint, decay,
median, passBucket.start, passBucket.end,
- 100 * passBucket.withinTarget / (passBucket.totalConfirmed + passBucket.inMempool + passBucket.leftMempool),
+ passed_within_target_perc,
passBucket.withinTarget, passBucket.totalConfirmed, passBucket.inMempool, passBucket.leftMempool,
failBucket.start, failBucket.end,
- 100 * failBucket.withinTarget / (failBucket.totalConfirmed + failBucket.inMempool + failBucket.leftMempool),
+ failed_within_target_perc,
failBucket.withinTarget, failBucket.totalConfirmed, failBucket.inMempool, failBucket.leftMempool);