| 667 | } |
| 668 | |
| 669 | CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThreshold, FeeEstimateHorizon horizon, EstimationResult* result) const |
| 670 | { |
| 671 | TxConfirmStats* stats = nullptr; |
| 672 | double sufficientTxs = SUFFICIENT_FEETXS; |
| 673 | switch (horizon) { |
| 674 | case FeeEstimateHorizon::SHORT_HALFLIFE: { |
| 675 | stats = shortStats.get(); |
| 676 | sufficientTxs = SUFFICIENT_TXS_SHORT; |
| 677 | break; |
| 678 | } |
| 679 | case FeeEstimateHorizon::MED_HALFLIFE: { |
| 680 | stats = feeStats.get(); |
| 681 | break; |
| 682 | } |
| 683 | case FeeEstimateHorizon::LONG_HALFLIFE: { |
| 684 | stats = longStats.get(); |
| 685 | break; |
| 686 | } |
| 687 | } // no default case, so the compiler can warn about missing cases |
| 688 | assert(stats); |
| 689 | |
| 690 | LOCK(m_cs_fee_estimator); |
| 691 | // Return failure if trying to analyze a target we're not tracking |
| 692 | if (confTarget <= 0 || (unsigned int)confTarget > stats->GetMaxConfirms()) |
| 693 | return CFeeRate(0); |
| 694 | if (successThreshold > 1) |
| 695 | return CFeeRate(0); |
| 696 | |
| 697 | double median = stats->EstimateMedianVal(confTarget, sufficientTxs, successThreshold, nBestSeenHeight, result); |
| 698 | |
| 699 | if (median < 0) |
| 700 | return CFeeRate(0); |
| 701 | |
| 702 | return CFeeRate(llround(median)); |
| 703 | } |
| 704 | |
| 705 | unsigned int CBlockPolicyEstimator::HighestTargetTracked(FeeEstimateHorizon horizon) const |
| 706 | { |