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) { 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