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) {
|
||||
var height = entry.height;
|
||||
var hash = entry.tx.hash('hex');
|
||||
var fee, rate, priority;
|
||||
var fee, rate, priority, stat;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -531,20 +533,22 @@ PolicyEstimator.prototype.processTX = function processTX(entry, current) {
|
||||
this.logger.spam('estimatefee: Processing mempool tx %s.', entry.tx.rhash);
|
||||
|
||||
if (fee === 0 || this.isPriPoint(rate, priority)) {
|
||||
this.map[hash] = {
|
||||
blockHeight: height,
|
||||
bucketIndex: this.priStats.addTX(height, priority)
|
||||
};
|
||||
this.mapSize++;
|
||||
stat = new StatEntry();
|
||||
stat.blockHeight = height;
|
||||
stat.bucketIndex = this.priStats.addTX(height, priority);
|
||||
} else if (this.isFeePoint(rate, priority)) {
|
||||
this.map[hash] = {
|
||||
blockHeight: height,
|
||||
bucketIndex: this.feeStats.addTX(height, rate)
|
||||
};
|
||||
this.mapSize++;
|
||||
} else {
|
||||
this.logger.spam('estimatefee: Not adding tx %s.', entry.tx.rhash);
|
||||
stat = new StatEntry();
|
||||
stat.blockHeight = height;
|
||||
stat.bucketIndex = this.feeStats.addTX(height, rate);
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
/**
|
||||
* StatEntry
|
||||
* @private
|
||||
*/
|
||||
|
||||
function StatEntry() {
|
||||
this.blockHeight = -1;
|
||||
this.bucketIndex = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* DoubleMap
|
||||
* @private
|
||||
|
||||
Loading…
Reference in New Issue
Block a user