Skip to content

Commit 10f7cbd

Browse files
committed
Track first recorded height
Track the first time we seen txs in a block that we have been tracking in our mempool. Used to evaluate validity of fee estimates for different targets.
1 parent 3810e97 commit 10f7cbd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/policy/fees.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ bool CBlockPolicyEstimator::removeTx(uint256 hash, bool inBlock)
477477
}
478478

479479
CBlockPolicyEstimator::CBlockPolicyEstimator()
480-
: nBestSeenHeight(0), trackedTxs(0), untrackedTxs(0)
480+
: nBestSeenHeight(0), firstRecordedHeight(0), trackedTxs(0), untrackedTxs(0)
481481
{
482482
static_assert(MIN_BUCKET_FEERATE > 0, "Min feerate must be nonzero");
483483
minTrackedFee = CFeeRate(MIN_BUCKET_FEERATE);
@@ -603,6 +603,11 @@ void CBlockPolicyEstimator::processBlock(unsigned int nBlockHeight,
603603
countedTxs++;
604604
}
605605

606+
if (firstRecordedHeight == 0 && countedTxs > 0) {
607+
firstRecordedHeight = nBestSeenHeight;
608+
LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy first recorded height %u\n", firstRecordedHeight);
609+
}
610+
606611

607612
LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy after updating estimates for %u of %u txs in block, since last block %u of %u tracked, new mempool map size %u\n",
608613
countedTxs, entries.size(), trackedTxs, trackedTxs + untrackedTxs, mapMemPoolTxs.size());

src/policy/fees.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ class CBlockPolicyEstimator
173173
private:
174174
CFeeRate minTrackedFee; //!< Passed to constructor to avoid dependency on main
175175
unsigned int nBestSeenHeight;
176+
unsigned int firstRecordedHeight;
177+
unsigned int historicalFirst;
178+
unsigned int historicalBest;
179+
176180
struct TxStatsInfo
177181
{
178182
unsigned int blockHeight;

0 commit comments

Comments
 (0)