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