Improve api to estimatesmartfee
Change parameter for conservative estimates to be an estimate_mode string. Change to never return a -1 for failure but to instead omit the feerate and return an error string. Throw JSONRPC error on invalid nblocks parameter.
This commit is contained in:
+8
-11
@@ -839,20 +839,20 @@ CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, FeeCalculation
|
||||
EstimationResult tempResult;
|
||||
|
||||
// Return failure if trying to analyze a target we're not tracking
|
||||
if (confTarget <= 0 || (unsigned int)confTarget > longStats->GetMaxConfirms())
|
||||
return CFeeRate(0);
|
||||
if (confTarget <= 0 || (unsigned int)confTarget > longStats->GetMaxConfirms()) {
|
||||
return CFeeRate(0); // error conditon
|
||||
}
|
||||
|
||||
// It's not possible to get reasonable estimates for confTarget of 1
|
||||
if (confTarget == 1)
|
||||
confTarget = 2;
|
||||
if (confTarget == 1) confTarget = 2;
|
||||
|
||||
unsigned int maxUsableEstimate = MaxUsableEstimate();
|
||||
if (maxUsableEstimate <= 1)
|
||||
return CFeeRate(0);
|
||||
|
||||
if ((unsigned int)confTarget > maxUsableEstimate) {
|
||||
confTarget = maxUsableEstimate;
|
||||
}
|
||||
if (feeCalc) feeCalc->returnedTarget = confTarget;
|
||||
|
||||
if (confTarget <= 1) return CFeeRate(0); // error conditon
|
||||
|
||||
assert(confTarget > 0); //estimateCombinedFee and estimateConservativeFee take unsigned ints
|
||||
/** true is passed to estimateCombined fee for target/2 and target so
|
||||
@@ -899,10 +899,7 @@ CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, FeeCalculation
|
||||
}
|
||||
}
|
||||
|
||||
if (feeCalc) feeCalc->returnedTarget = confTarget;
|
||||
|
||||
if (median < 0)
|
||||
return CFeeRate(0);
|
||||
if (median < 0) return CFeeRate(0); // error conditon
|
||||
|
||||
return CFeeRate(median);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user