12
12
#include < txmempool.h>
13
13
#include < util/system.h>
14
14
15
- static const char * FEE_ESTIMATES_FILENAME= " fee_estimates.dat" ;
15
+ static const char * FEE_ESTIMATES_FILENAME = " fee_estimates.dat" ;
16
16
17
17
static constexpr double INF_FEERATE = 1e99 ;
18
18
19
- std::string StringForFeeEstimateHorizon (FeeEstimateHorizon horizon) {
20
- static const std::map<FeeEstimateHorizon, std::string> horizon_strings = {
21
- {FeeEstimateHorizon::SHORT_HALFLIFE, " short" },
22
- {FeeEstimateHorizon::MED_HALFLIFE, " medium" },
23
- {FeeEstimateHorizon::LONG_HALFLIFE, " long" },
24
- };
25
- auto horizon_string = horizon_strings.find (horizon);
26
-
27
- if (horizon_string == horizon_strings.end ()) return " unknown" ;
28
-
29
- return horizon_string->second ;
19
+ std::string StringForFeeEstimateHorizon (FeeEstimateHorizon horizon)
20
+ {
21
+ switch (horizon) {
22
+ case FeeEstimateHorizon::SHORT_HALFLIFE: return " short" ;
23
+ case FeeEstimateHorizon::MED_HALFLIFE: return " medium" ;
24
+ case FeeEstimateHorizon::LONG_HALFLIFE: return " long" ;
25
+ } // no default case, so the compiler can warn about missing cases
26
+ assert (false );
30
27
}
31
28
32
29
/* *
@@ -644,7 +641,7 @@ CFeeRate CBlockPolicyEstimator::estimateFee(int confTarget) const
644
641
645
642
CFeeRate CBlockPolicyEstimator::estimateRawFee (int confTarget, double successThreshold, FeeEstimateHorizon horizon, EstimationResult* result) const
646
643
{
647
- TxConfirmStats* stats;
644
+ TxConfirmStats* stats = nullptr ;
648
645
double sufficientTxs = SUFFICIENT_FEETXS;
649
646
switch (horizon) {
650
647
case FeeEstimateHorizon::SHORT_HALFLIFE: {
@@ -660,10 +657,8 @@ CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThr
660
657
stats = longStats.get ();
661
658
break ;
662
659
}
663
- default : {
664
- throw std::out_of_range (" CBlockPolicyEstimator::estimateRawFee unknown FeeEstimateHorizon" );
665
- }
666
- }
660
+ } // no default case, so the compiler can warn about missing cases
661
+ assert (stats);
667
662
668
663
LOCK (m_cs_fee_estimator);
669
664
// Return failure if trying to analyze a target we're not tracking
@@ -693,10 +688,8 @@ unsigned int CBlockPolicyEstimator::HighestTargetTracked(FeeEstimateHorizon hori
693
688
case FeeEstimateHorizon::LONG_HALFLIFE: {
694
689
return longStats->GetMaxConfirms ();
695
690
}
696
- default : {
697
- throw std::out_of_range (" CBlockPolicyEstimator::HighestTargetTracked unknown FeeEstimateHorizon" );
698
- }
699
- }
691
+ } // no default case, so the compiler can warn about missing cases
692
+ assert (false );
700
693
}
701
694
702
695
unsigned int CBlockPolicyEstimator::BlockSpan () const
0 commit comments