fees: refactor.

This commit is contained in:
Christopher Jeffrey 2016-08-22 22:36:58 -07:00
parent 9ced2df5fa
commit 5e49bce310
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -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