diff --git a/lib/mempool/fees.js b/lib/mempool/fees.js index bc3436ab..ef1482ce 100644 --- a/lib/mempool/fees.js +++ b/lib/mempool/fees.js @@ -656,13 +656,13 @@ PolicyEstimator.prototype.processBlock = function processBlock(height, entries, /** * Estimate a fee rate. - * @param {Number} target - Confirmation target. + * @param {Number} [target=1] - Confirmation target. * @param {Boolean} [smart=true] - Smart estimation. * @returns {Rate} */ PolicyEstimator.prototype.estimateFee = function estimateFee(target, smart) { - var rate, minPoolFee; + var rate; if (!target) target = 1; @@ -670,8 +670,9 @@ PolicyEstimator.prototype.estimateFee = function estimateFee(target, smart) { if (smart == null) smart = true; - if (!(target > 0) || target > this.feeStats.maxConfirms) - return 0; + assert(utils.isUInt32(target), 'Target must be a number.'); + assert(target <= this.feeStats.maxConfirms, + 'Too many confirmations for estimate.'); if (!smart) { rate = this.feeStats.estimateMedian( @@ -693,9 +694,8 @@ PolicyEstimator.prototype.estimateFee = function estimateFee(target, smart) { target -= 1; - minPoolFee = this.network.minRelay; - if (minPoolFee > 0 && minPoolFee > rate) - return minPoolFee; + if (rate < this.network.feeRate) + return this.network.feeRate; if (rate < 0) return 0; @@ -705,13 +705,13 @@ PolicyEstimator.prototype.estimateFee = function estimateFee(target, smart) { /** * Estimate a priority. - * @param {Number} target - Confirmation target. + * @param {Number} [target=1] - Confirmation target. * @param {Boolean} [smart=true] - Smart estimation. * @returns {Number} */ PolicyEstimator.prototype.estimatePriority = function estimatePriority(target, smart) { - var minPoolFee, priority; + var priority; if (!target) target = 1; @@ -719,8 +719,9 @@ PolicyEstimator.prototype.estimatePriority = function estimatePriority(target, s if (smart == null) smart = true; - if (!(target > 0) || target > this.priStats.maxConfirms) - return 0; + assert(utils.isUInt32(target), 'Target must be a number.'); + assert(target <= this.priStats.maxConfirms, + 'Too many confirmations for estimate.'); if (!smart) { priority = this.priStats.estimateMedian( @@ -729,9 +730,8 @@ PolicyEstimator.prototype.estimatePriority = function estimatePriority(target, s return Math.floor(priority); } - minPoolFee = this.network.minRelay; - if (minPoolFee > 0) - return INF_PRIORITY; + // TODO: Add check for mempool limiting txs. + // Should return INF_PRIORITY. priority = -1; while (priority < 0 && target <= this.priStats.maxConfirms) {