fees: refactor.
This commit is contained in:
parent
9ced2df5fa
commit
5e49bce310
@ -505,10 +505,12 @@ PolicyEstimator.prototype.isPriPoint = function isPriPoint(fee, priority) {
|
|||||||
PolicyEstimator.prototype.processTX = function processTX(entry, current) {
|
PolicyEstimator.prototype.processTX = function processTX(entry, current) {
|
||||||
var height = entry.height;
|
var height = entry.height;
|
||||||
var hash = entry.tx.hash('hex');
|
var hash = entry.tx.hash('hex');
|
||||||
var fee, rate, priority;
|
var fee, rate, priority, stat;
|
||||||
|
|
||||||
if (this.map[hash]) {
|
if (this.map[hash]) {
|
||||||
this.logger.debug('estimatefee: Mempool tx %s already tracked.', entry.tx.rhash);
|
this.logger.debug(
|
||||||
|
'estimatefee: Mempool tx %s already tracked.',
|
||||||
|
entry.tx.rhash);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,20 +533,22 @@ PolicyEstimator.prototype.processTX = function processTX(entry, current) {
|
|||||||
this.logger.spam('estimatefee: Processing mempool tx %s.', entry.tx.rhash);
|
this.logger.spam('estimatefee: Processing mempool tx %s.', entry.tx.rhash);
|
||||||
|
|
||||||
if (fee === 0 || this.isPriPoint(rate, priority)) {
|
if (fee === 0 || this.isPriPoint(rate, priority)) {
|
||||||
this.map[hash] = {
|
stat = new StatEntry();
|
||||||
blockHeight: height,
|
stat.blockHeight = height;
|
||||||
bucketIndex: this.priStats.addTX(height, priority)
|
stat.bucketIndex = this.priStats.addTX(height, priority);
|
||||||
};
|
|
||||||
this.mapSize++;
|
|
||||||
} else if (this.isFeePoint(rate, priority)) {
|
} else if (this.isFeePoint(rate, priority)) {
|
||||||
this.map[hash] = {
|
stat = new StatEntry();
|
||||||
blockHeight: height,
|
stat.blockHeight = height;
|
||||||
bucketIndex: this.feeStats.addTX(height, rate)
|
stat.bucketIndex = this.feeStats.addTX(height, rate);
|
||||||
};
|
|
||||||
this.mapSize++;
|
|
||||||
} else {
|
|
||||||
this.logger.spam('estimatefee: Not adding tx %s.', entry.tx.rhash);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!stat) {
|
||||||
|
this.logger.spam('estimatefee: Not adding tx %s.', entry.tx.rhash);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.map[hash] = stat;
|
||||||
|
this.mapSize++;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -785,6 +789,16 @@ PolicyEstimator.fromRaw = function fromRaw(minRelay, data, logger) {
|
|||||||
return estimator;
|
return estimator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StatEntry
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function StatEntry() {
|
||||||
|
this.blockHeight = -1;
|
||||||
|
this.bucketIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DoubleMap
|
* DoubleMap
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user