aboutsummaryrefslogtreecommitdiff
path: root/src/policy/fees.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2021-02-13 17:38:34 +1000
committerAnthony Towns <aj@erisian.com.au>2022-09-02 22:29:53 +1000
commita5e39d325da4eeb9273fb7c919fcbfbc721ed75d (patch)
tree9eb9fcab0f48807cdf86b2ff28922ee1dceb00c5 /src/policy/fees.cpp
parente191fac4f3c37820f0618f72f0a8e8b524531ab8 (diff)
downloadbitcoin-a5e39d325da4eeb9273fb7c919fcbfbc721ed75d.tar.xz
Fee estimation: extend bucket ranges consistently
When calculating a median fee for a confirmation target at a particular threshold, we analyse buckets in ranges rather than individually in case some buckets have very little data. This patch ensures the breaks between ranges are independent of the the confirmation target.
Diffstat (limited to 'src/policy/fees.cpp')
-rw-r--r--src/policy/fees.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp
index 2b940be07e..6a83f4980a 100644
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -259,6 +259,11 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal,
unsigned int curFarBucket = maxbucketindex;
unsigned int bestFarBucket = maxbucketindex;
+ // We'll always group buckets into sets that meet sufficientTxVal --
+ // this ensures that we're using consistent groups between different
+ // confirmation targets.
+ double partialNum = 0;
+
bool foundAnswer = false;
unsigned int bins = unconfTxs.size();
bool newBucketRange = true;
@@ -274,6 +279,7 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal,
}
curFarBucket = bucket;
nConf += confAvg[periodTarget - 1][bucket];
+ partialNum += txCtAvg[bucket];
totalNum += txCtAvg[bucket];
failNum += failAvg[periodTarget - 1][bucket];
for (unsigned int confct = confTarget; confct < GetMaxConfirms(); confct++)
@@ -283,7 +289,14 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal,
// we can test for success
// (Only count the confirmed data points, so that each confirmation count
// will be looking at the same amount of data and same bucket breaks)
- if (totalNum >= sufficientTxVal / (1 - decay)) {
+
+ if (partialNum < sufficientTxVal / (1 - decay)) {
+ // the buckets we've added in this round aren't sufficient
+ // so keep adding
+ continue;
+ } else {
+ partialNum = 0; // reset for the next range we'll add
+
double curPct = nConf / (totalNum + failNum + extraNum);
// Check to see if we are no longer getting confirmed at the success rate