fees refactor.
This commit is contained in:
parent
927fb9c555
commit
84a04b33e5
@ -433,7 +433,7 @@ PolicyEstimator.prototype.processTX = function processTX(entry, current) {
|
|||||||
blockHeight: height,
|
blockHeight: height,
|
||||||
bucketIndex: this.feeStats.addTX(height, rate)
|
bucketIndex: this.feeStats.addTX(height, rate)
|
||||||
};
|
};
|
||||||
bcoin.debug('estimatefee: Rate: %d.', this.estimateFee(1, true));
|
bcoin.debug('estimatefee: Rate: %d.', this.estimateFee());
|
||||||
} else {
|
} else {
|
||||||
bcoin.debug('estimatefee: Not adding ts %s.', hash);
|
bcoin.debug('estimatefee: Not adding ts %s.', hash);
|
||||||
}
|
}
|
||||||
@ -477,7 +477,7 @@ PolicyEstimator.prototype.processBlockTX = function processBlockTX(height, entry
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
PolicyEstimator.prototype.processBlock = function processBlock(height, entries, current) {
|
PolicyEstimator.prototype.processBlock = function processBlock(height, entries, current) {
|
||||||
var i, median;
|
var i;
|
||||||
|
|
||||||
// Ignore reorgs.
|
// Ignore reorgs.
|
||||||
if (height <= this.bestHeight)
|
if (height <= this.bestHeight)
|
||||||
@ -494,6 +494,20 @@ PolicyEstimator.prototype.processBlock = function processBlock(height, entries,
|
|||||||
|
|
||||||
bcoin.debug('estimatefee: Recalculating dynamic cutoffs.');
|
bcoin.debug('estimatefee: Recalculating dynamic cutoffs.');
|
||||||
|
|
||||||
|
this.feeLikely = this.feeStats.estimateMedian(
|
||||||
|
2, SUFFICIENT_FEETXS, MIN_SUCCESS_PCT,
|
||||||
|
true, height);
|
||||||
|
|
||||||
|
if (this.feeLikely === -1)
|
||||||
|
this.feeLikely = INF_FEERATE;
|
||||||
|
|
||||||
|
this.feeUnlikely = this.feeStats.estimateMedian(
|
||||||
|
10, SUFFICIENT_FEETXS, UNLIKELY_PCT,
|
||||||
|
false, height);
|
||||||
|
|
||||||
|
if (this.feeUnlikely === -1)
|
||||||
|
this.feeUnlikely = 0;
|
||||||
|
|
||||||
this.priLikely = this.priStats.estimateMedian(
|
this.priLikely = this.priStats.estimateMedian(
|
||||||
2, SUFFICIENT_PRITXS, MIN_SUCCESS_PCT,
|
2, SUFFICIENT_PRITXS, MIN_SUCCESS_PCT,
|
||||||
true, height);
|
true, height);
|
||||||
@ -501,12 +515,6 @@ PolicyEstimator.prototype.processBlock = function processBlock(height, entries,
|
|||||||
if (this.priLikely === -1)
|
if (this.priLikely === -1)
|
||||||
this.priLikely = INF_PRIORITY;
|
this.priLikely = INF_PRIORITY;
|
||||||
|
|
||||||
median = this.feeStats.estimateMedian(
|
|
||||||
2, SUFFICIENT_FEETXS, MIN_SUCCESS_PCT,
|
|
||||||
true, height);
|
|
||||||
|
|
||||||
this.feeLikely = median === -1 ? INF_FEERATE : median;
|
|
||||||
|
|
||||||
this.priUnlikely = this.priStats.estimateMedian(
|
this.priUnlikely = this.priStats.estimateMedian(
|
||||||
10, SUFFICIENT_PRITXS, UNLIKELY_PCT,
|
10, SUFFICIENT_PRITXS, UNLIKELY_PCT,
|
||||||
false, height);
|
false, height);
|
||||||
@ -514,12 +522,6 @@ PolicyEstimator.prototype.processBlock = function processBlock(height, entries,
|
|||||||
if (this.priUnlikely === -1)
|
if (this.priUnlikely === -1)
|
||||||
this.priUnlikely = 0;
|
this.priUnlikely = 0;
|
||||||
|
|
||||||
median = this.feeStats.estimateMedian(
|
|
||||||
10, SUFFICIENT_FEETXS, UNLIKELY_PCT,
|
|
||||||
false, height);
|
|
||||||
|
|
||||||
this.feeUnlikely = median === -1 ? 0 : median;
|
|
||||||
|
|
||||||
this.feeStats.clearCurrent(height);
|
this.feeStats.clearCurrent(height);
|
||||||
this.priStats.clearCurrent(height);
|
this.priStats.clearCurrent(height);
|
||||||
|
|
||||||
@ -537,14 +539,20 @@ PolicyEstimator.prototype.processBlock = function processBlock(height, entries,
|
|||||||
/**
|
/**
|
||||||
* Estimate a fee rate.
|
* Estimate a fee rate.
|
||||||
* @param {Number} target - Confirmation target.
|
* @param {Number} target - Confirmation target.
|
||||||
* @param {Boolean?} smart - Smart estimation.
|
* @param {Boolean} [smart=true] - Smart estimation.
|
||||||
* @returns {Rate}
|
* @returns {Rate}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PolicyEstimator.prototype.estimateFee = function estimateFee(target, smart) {
|
PolicyEstimator.prototype.estimateFee = function estimateFee(target, smart) {
|
||||||
var rate, minPoolFee;
|
var rate, minPoolFee;
|
||||||
|
|
||||||
if (target <= 0 || target > this.feeStats.maxConfirms)
|
if (!target)
|
||||||
|
target = 1;
|
||||||
|
|
||||||
|
if (smart == null)
|
||||||
|
smart = true;
|
||||||
|
|
||||||
|
if (!(target > 0) || target > this.feeStats.maxConfirms)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!smart) {
|
if (!smart) {
|
||||||
@ -580,15 +588,21 @@ PolicyEstimator.prototype.estimateFee = function estimateFee(target, smart) {
|
|||||||
/**
|
/**
|
||||||
* Estimate a priority.
|
* Estimate a priority.
|
||||||
* @param {Number} target - Confirmation target.
|
* @param {Number} target - Confirmation target.
|
||||||
* @param {Boolean?} smart - Smart estimation.
|
* @param {Boolean} [smart=true] - Smart estimation.
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PolicyEstimator.prototype.estimatePriority = function estimatePriority(target, smart) {
|
PolicyEstimator.prototype.estimatePriority = function estimatePriority(target, smart) {
|
||||||
var minPoolFee, priority;
|
var minPoolFee, priority;
|
||||||
|
|
||||||
if (target <= 0 || target > this.priStats.maxConfirms)
|
if (!target)
|
||||||
return -1;
|
target = 1;
|
||||||
|
|
||||||
|
if (smart == null)
|
||||||
|
smart = true;
|
||||||
|
|
||||||
|
if (!(target > 0) || target > this.priStats.maxConfirms)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!smart) {
|
if (!smart) {
|
||||||
priority = this.priStats.estimateMedian(
|
priority = this.priStats.estimateMedian(
|
||||||
@ -610,6 +624,9 @@ PolicyEstimator.prototype.estimatePriority = function estimatePriority(target, s
|
|||||||
|
|
||||||
target -= 1;
|
target -= 1;
|
||||||
|
|
||||||
|
if (priority < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return priority;
|
return priority;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user