aboutsummaryrefslogtreecommitdiff
path: root/src/policy/fees.cpp
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2023-11-02 11:14:11 +0000
committerglozow <gloriajzhao@gmail.com>2023-11-02 11:25:50 +0000
commit2e9454a633462604cfafdf685cc9b3ad7d0e56ef (patch)
tree0e2b6f31654663cc72269e393cd891e636dbe82a /src/policy/fees.cpp
parent023418a140b05b788b45fcb66bdd4832c08db751 (diff)
parenta5e39d325da4eeb9273fb7c919fcbfbc721ed75d (diff)
downloadbitcoin-2e9454a633462604cfafdf685cc9b3ad7d0e56ef.tar.xz
Merge bitcoin/bitcoin#21161: Fee estimation: extend bucket ranges consistently
a5e39d325da4eeb9273fb7c919fcbfbc721ed75d Fee estimation: extend bucket ranges consistently (Anthony Towns) Pull request description: 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. Fixes #20725 ACKs for top commit: ismaelsadeeq: Code review ACK a5e39d325da4eeb9273fb7c919fcbfbc721ed75d glozow: btw what I meant by [this](https://github.com/bitcoin/bitcoin/pull/21161#pullrequestreview-1350258467) was ACK a5e39d325da4eeb9273fb7c919fcbfbc721ed75d jonatack: Initial ACK a5e39d325da4eeb9273fb7c919fcbfbc721ed75d Tree-SHA512: 0edf4e56717c4ab8d4ab0bc0f1d7ab36a13b99de12f689e55c9142c6b81691367ffd8df2e8260c5e14335310b1a51770c6c22995db31109976239befcb558ef8
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 87bfa4cfc3..9557594622 100644
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -260,6 +260,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;
@@ -275,6 +280,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++)
@@ -284,7 +290,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