Skip to content

Commit 1fafd70

Browse files
committed
Add function to report highest estimate target tracked per horizon
1 parent 9c85b91 commit 1fafd70

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/policy/fees.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThr
684684
break;
685685
}
686686
default: {
687-
return CFeeRate(0);
687+
throw std::out_of_range("CBlockPoicyEstimator::estimateRawFee unknown FeeEstimateHorizon");
688688
}
689689
}
690690

@@ -703,6 +703,24 @@ CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThr
703703
return CFeeRate(median);
704704
}
705705

706+
unsigned int CBlockPolicyEstimator::HighestTargetTracked(FeeEstimateHorizon horizon) const
707+
{
708+
switch (horizon) {
709+
case FeeEstimateHorizon::SHORT_HALFLIFE: {
710+
return shortStats->GetMaxConfirms();
711+
}
712+
case FeeEstimateHorizon::MED_HALFLIFE: {
713+
return feeStats->GetMaxConfirms();
714+
}
715+
case FeeEstimateHorizon::LONG_HALFLIFE: {
716+
return longStats->GetMaxConfirms();
717+
}
718+
default: {
719+
throw std::out_of_range("CBlockPoicyEstimator::HighestTargetTracked unknown FeeEstimateHorizon");
720+
}
721+
}
722+
}
723+
706724
unsigned int CBlockPolicyEstimator::BlockSpan() const
707725
{
708726
if (firstRecordedHeight == 0) return 0;

src/policy/fees.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ class CBlockPolicyEstimator
216216
/** Empty mempool transactions on shutdown to record failure to confirm for txs still in mempool */
217217
void FlushUnconfirmed(CTxMemPool& pool);
218218

219+
/** Calculation of highest target that estimates are tracked for */
220+
unsigned int HighestTargetTracked(FeeEstimateHorizon horizon) const;
221+
219222
private:
220223
unsigned int nBestSeenHeight;
221224
unsigned int firstRecordedHeight;

0 commit comments

Comments
 (0)