예제 #1
0
        public int HighestTargetTracked(FeeEstimateHorizon horizon)
        {
            switch (horizon)
            {
            case FeeEstimateHorizon.ShortHalfLife:
            {
                return(this.shortStats.GetMaxConfirms());
            }

            case FeeEstimateHorizon.MedHalfLife:
            {
                return(this.feeStats.GetMaxConfirms());
            }

            case FeeEstimateHorizon.LongHalfLife:
            {
                return(this.longStats.GetMaxConfirms());
            }

            default:
            {
                throw new ArgumentException(nameof(horizon));
            }
            }
        }
예제 #2
0
        /// <summary>
        /// Return an estimate fee according to horizon
        /// </summary>
        /// <param name="confTarget">The desired number of confirmations to be included in a block</param>
        public FeeRate EstimateRawFee(int confTarget, double successThreshold, FeeEstimateHorizon horizon, EstimationResult result)
        {
            TxConfirmStats stats;
            double         sufficientTxs = SufficientFeeTxs;

            switch (horizon)
            {
            case FeeEstimateHorizon.ShortHalfLife:
            {
                stats         = this.shortStats;
                sufficientTxs = SufficientTxsShort;
                break;
            }

            case FeeEstimateHorizon.MedHalfLife:
            {
                stats = this.feeStats;
                break;
            }

            case FeeEstimateHorizon.LongHalfLife:
            {
                stats = this.longStats;
                break;
            }

            default:
            {
                throw new ArgumentException(nameof(horizon));
            }
            }
            lock (this.lockObject)
            {
                // Return failure if trying to analyze a target we're not tracking
                if (confTarget <= 0 || confTarget > stats.GetMaxConfirms())
                {
                    return(new FeeRate(0));
                }
                if (successThreshold > 1)
                {
                    return(new FeeRate(0));
                }

                double median = stats.EstimateMedianVal(confTarget, sufficientTxs, successThreshold,
                                                        true, this.nBestSeenHeight, result);

                if (median < 0)
                {
                    return(new FeeRate(0));
                }

                return(new FeeRate(Convert.ToInt64(median)));
            }
        }