aboutsummaryrefslogtreecommitdiff
path: root/src/policy
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-12-26 13:00:48 +0100
committerMarcoFalke <falke.marco@gmail.com>2020-12-26 17:32:14 +0100
commitfaccf8b1e1af293dfe9158d732718e7798a2fd89 (patch)
tree7b76af65e3140f7881acb5756512a9c409a041d4 /src/policy
parent43fc7a569c135a9f24db23e6fcbb30b839859094 (diff)
downloadbitcoin-faccf8b1e1af293dfe9158d732718e7798a2fd89.tar.xz
refactor: Enable -Wswitch for FeeEstimateHorizon
Diffstat (limited to 'src/policy')
-rw-r--r--src/policy/fees.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp
index cfa4cf8421..462f231eba 100644
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -12,21 +12,18 @@
#include <txmempool.h>
#include <util/system.h>
-static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
+static const char* FEE_ESTIMATES_FILENAME = "fee_estimates.dat";
static constexpr double INF_FEERATE = 1e99;
-std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon) {
- static const std::map<FeeEstimateHorizon, std::string> horizon_strings = {
- {FeeEstimateHorizon::SHORT_HALFLIFE, "short"},
- {FeeEstimateHorizon::MED_HALFLIFE, "medium"},
- {FeeEstimateHorizon::LONG_HALFLIFE, "long"},
- };
- auto horizon_string = horizon_strings.find(horizon);
-
- if (horizon_string == horizon_strings.end()) return "unknown";
-
- return horizon_string->second;
+std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon)
+{
+ switch (horizon) {
+ case FeeEstimateHorizon::SHORT_HALFLIFE: return "short";
+ case FeeEstimateHorizon::MED_HALFLIFE: return "medium";
+ case FeeEstimateHorizon::LONG_HALFLIFE: return "long";
+ } // no default case, so the compiler can warn about missing cases
+ assert(false);
}
/**
@@ -644,7 +641,7 @@ CFeeRate CBlockPolicyEstimator::estimateFee(int confTarget) const
CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThreshold, FeeEstimateHorizon horizon, EstimationResult* result) const
{
- TxConfirmStats* stats;
+ TxConfirmStats* stats = nullptr;
double sufficientTxs = SUFFICIENT_FEETXS;
switch (horizon) {
case FeeEstimateHorizon::SHORT_HALFLIFE: {
@@ -660,10 +657,8 @@ CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThr
stats = longStats.get();
break;
}
- default: {
- throw std::out_of_range("CBlockPolicyEstimator::estimateRawFee unknown FeeEstimateHorizon");
- }
- }
+ } // no default case, so the compiler can warn about missing cases
+ assert(stats);
LOCK(m_cs_fee_estimator);
// 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: {
return longStats->GetMaxConfirms();
}
- default: {
- throw std::out_of_range("CBlockPolicyEstimator::HighestTargetTracked unknown FeeEstimateHorizon");
- }
- }
+ } // no default case, so the compiler can warn about missing cases
+ assert(false);
}
unsigned int CBlockPolicyEstimator::BlockSpan() const