Return a fee estimate at the required successThreshold from the shortest * time horizon which tracks confirmations up to the desired target. If * checkShorterHorizon is requested, also allow short time horizon estimates * for a lower target to reduce the given answer */
| 748 | * checkShorterHorizon is requested, also allow short time horizon estimates |
| 749 | * for a lower target to reduce the given answer */ |
| 750 | double CBlockPolicyEstimator::estimateCombinedFee(unsigned int confTarget, double successThreshold, bool checkShorterHorizon, EstimationResult *result) const |
| 751 | { |
| 752 | double estimate = -1; |
| 753 | if (confTarget >= 1 && confTarget <= longStats->GetMaxConfirms()) { |
| 754 | // Find estimate from shortest time horizon possible |
| 755 | if (confTarget <= shortStats->GetMaxConfirms()) { // short horizon |
| 756 | estimate = shortStats->EstimateMedianVal(confTarget, SUFFICIENT_TXS_SHORT, successThreshold, nBestSeenHeight, result); |
| 757 | } |
| 758 | else if (confTarget <= feeStats->GetMaxConfirms()) { // medium horizon |
| 759 | estimate = feeStats->EstimateMedianVal(confTarget, SUFFICIENT_FEETXS, successThreshold, nBestSeenHeight, result); |
| 760 | } |
| 761 | else { // long horizon |
| 762 | estimate = longStats->EstimateMedianVal(confTarget, SUFFICIENT_FEETXS, successThreshold, nBestSeenHeight, result); |
| 763 | } |
| 764 | if (checkShorterHorizon) { |
| 765 | EstimationResult tempResult; |
| 766 | // If a lower confTarget from a more recent horizon returns a lower answer use it. |
| 767 | if (confTarget > feeStats->GetMaxConfirms()) { |
| 768 | double medMax = feeStats->EstimateMedianVal(feeStats->GetMaxConfirms(), SUFFICIENT_FEETXS, successThreshold, nBestSeenHeight, &tempResult); |
| 769 | if (medMax > 0 && (estimate == -1 || medMax < estimate)) { |
| 770 | estimate = medMax; |
| 771 | if (result) *result = tempResult; |
| 772 | } |
| 773 | } |
| 774 | if (confTarget > shortStats->GetMaxConfirms()) { |
| 775 | double shortMax = shortStats->EstimateMedianVal(shortStats->GetMaxConfirms(), SUFFICIENT_TXS_SHORT, successThreshold, nBestSeenHeight, &tempResult); |
| 776 | if (shortMax > 0 && (estimate == -1 || shortMax < estimate)) { |
| 777 | estimate = shortMax; |
| 778 | if (result) *result = tempResult; |
| 779 | } |
| 780 | } |
| 781 | } |
| 782 | } |
| 783 | return estimate; |
| 784 | } |
| 785 | |
| 786 | /** Ensure that for a conservative estimate, the DOUBLE_SUCCESS_PCT is also met |
| 787 | * at 2 * target for any longer time horizons. |
nothing calls this directly
no test coverage detected