From 10f7cbd2471ae289d2846e09c4b088fdc0330c8f Mon Sep 17 00:00:00 2001 From: Alex Morcos Date: Tue, 7 Mar 2017 15:01:50 -0500 Subject: [PATCH] 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. --- src/policy/fees.cpp | 7 ++++++- src/policy/fees.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index 2b22d59ffb6..cba063aea90 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -477,7 +477,7 @@ bool CBlockPolicyEstimator::removeTx(uint256 hash, bool inBlock) } CBlockPolicyEstimator::CBlockPolicyEstimator() - : nBestSeenHeight(0), trackedTxs(0), untrackedTxs(0) + : nBestSeenHeight(0), firstRecordedHeight(0), trackedTxs(0), untrackedTxs(0) { static_assert(MIN_BUCKET_FEERATE > 0, "Min feerate must be nonzero"); minTrackedFee = CFeeRate(MIN_BUCKET_FEERATE); @@ -603,6 +603,11 @@ void CBlockPolicyEstimator::processBlock(unsigned int nBlockHeight, countedTxs++; } + if (firstRecordedHeight == 0 && countedTxs > 0) { + firstRecordedHeight = nBestSeenHeight; + LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy first recorded height %u\n", firstRecordedHeight); + } + 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", countedTxs, entries.size(), trackedTxs, trackedTxs + untrackedTxs, mapMemPoolTxs.size()); diff --git a/src/policy/fees.h b/src/policy/fees.h index 7064ad15c13..3184aa08aba 100644 --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -173,6 +173,10 @@ public: private: CFeeRate minTrackedFee; //!< Passed to constructor to avoid dependency on main unsigned int nBestSeenHeight; + unsigned int firstRecordedHeight; + unsigned int historicalFirst; + unsigned int historicalBest; + struct TxStatsInfo { unsigned int blockHeight;