@ -16,17 +16,14 @@ static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
static constexpr double INF_FEERATE = 1e99 ;
static constexpr double INF_FEERATE = 1e99 ;
std : : string StringForFeeEstimateHorizon ( FeeEstimateHorizon horizon ) {
std : : string StringForFeeEstimateHorizon ( FeeEstimateHorizon horizon )
static const std : : map < FeeEstimateHorizon , std : : string > horizon_strings = {
{
{ FeeEstimateHorizon : : SHORT_HALFLIFE , " short " } ,
switch ( horizon ) {
{ FeeEstimateHorizon : : MED_HALFLIFE , " medium " } ,
case FeeEstimateHorizon : : SHORT_HALFLIFE : return " short " ;
{ FeeEstimateHorizon : : LONG_HALFLIFE , " long " } ,
case FeeEstimateHorizon : : MED_HALFLIFE : return " medium " ;
} ;
case FeeEstimateHorizon : : LONG_HALFLIFE : return " long " ;
auto horizon_string = horizon_strings . find ( horizon ) ;
} // no default case, so the compiler can warn about missing cases
assert ( false ) ;
if ( horizon_string = = horizon_strings . end ( ) ) return " unknown " ;
return horizon_string - > second ;
}
}
/**
/**
@ -644,7 +641,7 @@ CFeeRate CBlockPolicyEstimator::estimateFee(int confTarget) const
CFeeRate CBlockPolicyEstimator : : estimateRawFee ( int confTarget , double successThreshold , FeeEstimateHorizon horizon , EstimationResult * result ) const
CFeeRate CBlockPolicyEstimator : : estimateRawFee ( int confTarget , double successThreshold , FeeEstimateHorizon horizon , EstimationResult * result ) const
{
{
TxConfirmStats * stats ;
TxConfirmStats * stats = nullptr ;
double sufficientTxs = SUFFICIENT_FEETXS ;
double sufficientTxs = SUFFICIENT_FEETXS ;
switch ( horizon ) {
switch ( horizon ) {
case FeeEstimateHorizon : : SHORT_HALFLIFE : {
case FeeEstimateHorizon : : SHORT_HALFLIFE : {
@ -660,10 +657,8 @@ CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThr
stats = longStats . get ( ) ;
stats = longStats . get ( ) ;
break ;
break ;
}
}
default : {
} // no default case, so the compiler can warn about missing cases
throw std : : out_of_range ( " CBlockPolicyEstimator::estimateRawFee unknown FeeEstimateHorizon " ) ;
assert ( stats ) ;
}
}
LOCK ( m_cs_fee_estimator ) ;
LOCK ( m_cs_fee_estimator ) ;
// Return failure if trying to analyze a target we're not tracking
// Return failure if trying to analyze a target we're not tracking
@ -693,10 +688,8 @@ unsigned int CBlockPolicyEstimator::HighestTargetTracked(FeeEstimateHorizon hori
case FeeEstimateHorizon : : LONG_HALFLIFE : {
case FeeEstimateHorizon : : LONG_HALFLIFE : {
return longStats - > GetMaxConfirms ( ) ;
return longStats - > GetMaxConfirms ( ) ;
}
}
default : {
} // no default case, so the compiler can warn about missing cases
throw std : : out_of_range ( " CBlockPolicyEstimator::HighestTargetTracked unknown FeeEstimateHorizon " ) ;
assert ( false ) ;
}
}
}
}
unsigned int CBlockPolicyEstimator : : BlockSpan ( ) const
unsigned int CBlockPolicyEstimator : : BlockSpan ( ) const