Skip to content

Commit 2e9454a

Browse files
committed
Merge bitcoin#21161: Fee estimation: extend bucket ranges consistently
a5e39d3 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 bitcoin#20725 ACKs for top commit: ismaelsadeeq: Code review ACK a5e39d3 glozow: btw what I meant by [this](bitcoin#21161 (review)) was ACK a5e39d3 jonatack: Initial ACK a5e39d3 Tree-SHA512: 0edf4e56717c4ab8d4ab0bc0f1d7ab36a13b99de12f689e55c9142c6b81691367ffd8df2e8260c5e14335310b1a51770c6c22995db31109976239befcb558ef8
2 parents 023418a + a5e39d3 commit 2e9454a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/policy/fees.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal,
260260
unsigned int curFarBucket = maxbucketindex;
261261
unsigned int bestFarBucket = maxbucketindex;
262262

263+
// We'll always group buckets into sets that meet sufficientTxVal --
264+
// this ensures that we're using consistent groups between different
265+
// confirmation targets.
266+
double partialNum = 0;
267+
263268
bool foundAnswer = false;
264269
unsigned int bins = unconfTxs.size();
265270
bool newBucketRange = true;
@@ -275,6 +280,7 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal,
275280
}
276281
curFarBucket = bucket;
277282
nConf += confAvg[periodTarget - 1][bucket];
283+
partialNum += txCtAvg[bucket];
278284
totalNum += txCtAvg[bucket];
279285
failNum += failAvg[periodTarget - 1][bucket];
280286
for (unsigned int confct = confTarget; confct < GetMaxConfirms(); confct++)
@@ -284,7 +290,14 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal,
284290
// we can test for success
285291
// (Only count the confirmed data points, so that each confirmation count
286292
// will be looking at the same amount of data and same bucket breaks)
287-
if (totalNum >= sufficientTxVal / (1 - decay)) {
293+
294+
if (partialNum < sufficientTxVal / (1 - decay)) {
295+
// the buckets we've added in this round aren't sufficient
296+
// so keep adding
297+
continue;
298+
} else {
299+
partialNum = 0; // reset for the next range we'll add
300+
288301
double curPct = nConf / (totalNum + failNum + extraNum);
289302

290303
// Check to see if we are no longer getting confirmed at the success rate

0 commit comments

Comments
 (0)