Merge #10543: Change API to estimaterawfee
5e3b7b5Improve error reporting for estimaterawfee (Alex Morcos)1fafd70Add function to report highest estimate target tracked per horizon (Alex Morcos)9c85b91Change API to estimaterawfee (Alex Morcos) Tree-SHA512: e624c6e7967e9e48abe49f5818bd674e5710e571cc093029d2f90d39fdfba3c1f30e83bf89f6dce97052b59a7d9636a64642ccfb26effd149c417d0afbed0c0b
This commit is contained in:
+32
-1
@@ -16,6 +16,19 @@
|
||||
|
||||
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 StringForFeeReason(FeeReason reason) {
|
||||
static const std::map<FeeReason, std::string> fee_reason_strings = {
|
||||
{FeeReason::NONE, "None"},
|
||||
@@ -685,7 +698,7 @@ CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThr
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return CFeeRate(0);
|
||||
throw std::out_of_range("CBlockPoicyEstimator::estimateRawFee unknown FeeEstimateHorizon");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -704,6 +717,24 @@ CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThr
|
||||
return CFeeRate(median);
|
||||
}
|
||||
|
||||
unsigned int CBlockPolicyEstimator::HighestTargetTracked(FeeEstimateHorizon horizon) const
|
||||
{
|
||||
switch (horizon) {
|
||||
case FeeEstimateHorizon::SHORT_HALFLIFE: {
|
||||
return shortStats->GetMaxConfirms();
|
||||
}
|
||||
case FeeEstimateHorizon::MED_HALFLIFE: {
|
||||
return feeStats->GetMaxConfirms();
|
||||
}
|
||||
case FeeEstimateHorizon::LONG_HALFLIFE: {
|
||||
return longStats->GetMaxConfirms();
|
||||
}
|
||||
default: {
|
||||
throw std::out_of_range("CBlockPoicyEstimator::HighestTargetTracked unknown FeeEstimateHorizon");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int CBlockPolicyEstimator::BlockSpan() const
|
||||
{
|
||||
if (firstRecordedHeight == 0) return 0;
|
||||
|
||||
Reference in New Issue
Block a user