diff --git a/lib/mempool/fees.js b/lib/mempool/fees.js index 56ffb6b0..42eff81f 100644 --- a/lib/mempool/fees.js +++ b/lib/mempool/fees.js @@ -73,7 +73,7 @@ function ConfirmStats(type, logger) { if (logger) { assert(typeof logger === 'object'); - this.logger = logger; + this.logger = logger.context('fees'); } } @@ -261,7 +261,7 @@ ConfirmStats.prototype.addTX = function addTX(height, val) { var bucketIndex = this.bucketMap.search(val); var blockIndex = height % this.unconfTX.length; this.unconfTX[blockIndex][bucketIndex]++; - this.logger.spam('estimatefee: Adding tx to %s.', this.type); + this.logger.spam('Adding tx to %s.', this.type); return bucketIndex; }; @@ -280,7 +280,7 @@ ConfirmStats.prototype.removeTX = function removeTX(entryHeight, bestHeight, buc blocksAgo = 0; if (blocksAgo < 0) { - this.logger.debug('estimatefee: Blocks ago is negative for mempool tx.'); + this.logger.debug('Blocks ago is negative for mempool tx.'); return; } @@ -288,8 +288,7 @@ ConfirmStats.prototype.removeTX = function removeTX(entryHeight, bestHeight, buc if (this.oldUnconfTX[bucketIndex] > 0) { this.oldUnconfTX[bucketIndex]--; } else { - this.logger.debug('estimatefee:' - + ' Mempool tx removed >25 blocks (bucket=%d).', + this.logger.debug('Mempool tx removed >25 blocks (bucket=%d).', bucketIndex); } } else { @@ -297,8 +296,7 @@ ConfirmStats.prototype.removeTX = function removeTX(entryHeight, bestHeight, buc if (this.unconfTX[blockIndex][bucketIndex] > 0) { this.unconfTX[blockIndex][bucketIndex]--; } else { - this.logger.debug('estimatefee:' - + ' Mempool tx removed (block=%d, bucket=%d).', + this.logger.debug('Mempool tx removed (block=%d, bucket=%d).', blockIndex, bucketIndex); } } @@ -445,9 +443,9 @@ function PolicyEstimator(logger) { if (logger) { assert(typeof logger === 'object'); - this.logger = logger; - this.feeStats.logger = logger; - this.priStats.logger = logger; + this.logger = logger.context('fees'); + this.feeStats.logger = this.logger; + this.priStats.logger = this.logger; } } @@ -514,9 +512,7 @@ PolicyEstimator.prototype.removeTX = function removeTX(hash) { var item = this.map.get(hash); if (!item) { - this.logger.spam( - 'estimatefee: Mempool tx %s not found.', - util.revHex(hash)); + this.logger.spam('Mempool tx %s not found.', util.revHex(hash)); return; } @@ -563,13 +559,11 @@ 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 hash = entry.hash('hex'); var fee, rate, priority, item; if (this.map.has(hash)) { - this.logger.debug( - 'estimatefee: Mempool tx %s already tracked.', - entry.tx.txid()); + this.logger.debug('Mempool tx %s already tracked.', entry.txid()); return; } @@ -589,7 +583,7 @@ PolicyEstimator.prototype.processTX = function processTX(entry, current) { rate = entry.getRate(); priority = entry.getPriority(height); - this.logger.spam('estimatefee: Processing mempool tx %s.', entry.tx.txid()); + this.logger.spam('Processing mempool tx %s.', entry.txid()); if (fee === 0 || this.isPriPoint(rate, priority)) { item = new StatEntry(); @@ -602,7 +596,7 @@ PolicyEstimator.prototype.processTX = function processTX(entry, current) { } if (!item) { - this.logger.spam('estimatefee: Not adding tx %s.', entry.tx.txid()); + this.logger.spam('Not adding tx %s.', entry.txid()); return; } @@ -625,8 +619,8 @@ PolicyEstimator.prototype.processBlockTX = function processBlockTX(height, entry blocks = height - entry.height; if (blocks <= 0) { this.logger.debug( - 'estimatefee: Block tx %s had negative blocks to confirm (%d, %d).', - entry.tx.txid(), + 'Block tx %s had negative blocks to confirm (%d, %d).', + entry.txid(), height, entry.height); return; @@ -665,7 +659,7 @@ PolicyEstimator.prototype.processBlock = function processBlock(height, entries, if (!current) return; - this.logger.debug('estimatefee: Recalculating dynamic cutoffs.'); + this.logger.debug('Recalculating dynamic cutoffs.'); this.feeLikely = this.feeStats.estimateMedian( 2, SUFFICIENT_FEETXS, MIN_SUCCESS_PCT, @@ -704,11 +698,11 @@ PolicyEstimator.prototype.processBlock = function processBlock(height, entries, this.feeStats.updateAverages(); this.priStats.updateAverages(); - this.logger.debug('estimatefee: Done updating estimates' + this.logger.debug('Done updating estimates' + ' for %d confirmed entries. New mempool map size %d.', entries.length, this.map.size); - this.logger.debug('estimatefee: Rate: %d.', this.estimateFee()); + this.logger.debug('New fee rate: %d.', this.estimateFee()); }; /**