pool: refactor logging.
This commit is contained in:
parent
72e4ddc2b0
commit
0a756aba34
@ -197,6 +197,7 @@ Pool.prototype._init = function _init() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.chain.on('reset', function() {
|
this.chain.on('reset', function() {
|
||||||
|
self.resetChain();
|
||||||
self.forceSync();
|
self.forceSync();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -263,7 +264,7 @@ Pool.prototype.resetChain = function resetChain() {
|
|||||||
if (!this.options.headers)
|
if (!this.options.headers)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!this.options.useCheckpoints)
|
if (!this.chain.options.useCheckpoints)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.headersFirst = false;
|
this.headersFirst = false;
|
||||||
@ -897,30 +898,7 @@ Pool.prototype._handleBlock = co(function* handleBlock(peer, block) {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.logger.level >= 4 && this.chain.total % 20 === 0) {
|
this.logStatus(block);
|
||||||
this.logger.debug('Status:'
|
|
||||||
+ ' ts=%s height=%d progress=%s'
|
|
||||||
+ ' blocks=%d orphans=%d active=%d'
|
|
||||||
+ ' target=%s peers=%d'
|
|
||||||
+ ' pending=%d jobs=%d',
|
|
||||||
util.date(block.ts),
|
|
||||||
this.chain.height,
|
|
||||||
(this.chain.getProgress() * 100).toFixed(2) + '%',
|
|
||||||
this.chain.total,
|
|
||||||
this.chain.orphanCount,
|
|
||||||
this.requestMap.size,
|
|
||||||
block.bits,
|
|
||||||
this.peers.size(),
|
|
||||||
this.locker.pending,
|
|
||||||
this.locker.jobs.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.chain.total % 2000 === 0) {
|
|
||||||
this.logger.info(
|
|
||||||
'Received 2000 more blocks (height=%d, hash=%s).',
|
|
||||||
this.chain.height,
|
|
||||||
block.rhash());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.headersFirst)
|
if (!this.headersFirst)
|
||||||
return;
|
return;
|
||||||
@ -947,6 +925,39 @@ Pool.prototype._handleBlock = co(function* handleBlock(peer, block) {
|
|||||||
peer.sendGetBlocks([hash], null);
|
peer.sendGetBlocks([hash], null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log sync status.
|
||||||
|
* @private
|
||||||
|
* @param {Block} block
|
||||||
|
*/
|
||||||
|
|
||||||
|
Pool.prototype.logStatus = function logStatus(block) {
|
||||||
|
if (this.logger.level >= 4 && this.chain.total % 20 === 0) {
|
||||||
|
this.logger.debug('Status:'
|
||||||
|
+ ' ts=%s height=%d progress=%s'
|
||||||
|
+ ' blocks=%d orphans=%d active=%d'
|
||||||
|
+ ' target=%s peers=%d'
|
||||||
|
+ ' pending=%d jobs=%d',
|
||||||
|
util.date(block.ts),
|
||||||
|
this.chain.height,
|
||||||
|
(this.chain.getProgress() * 100).toFixed(2) + '%',
|
||||||
|
this.chain.total,
|
||||||
|
this.chain.orphanCount,
|
||||||
|
this.requestMap.size,
|
||||||
|
block.bits,
|
||||||
|
this.peers.size(),
|
||||||
|
this.locker.pending,
|
||||||
|
this.locker.jobs.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.chain.total % 2000 === 0) {
|
||||||
|
this.logger.info(
|
||||||
|
'Received 2000 more blocks (height=%d, hash=%s).',
|
||||||
|
this.chain.height,
|
||||||
|
block.rhash());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a transaction. Attempt to add to mempool.
|
* Handle a transaction. Attempt to add to mempool.
|
||||||
* @private
|
* @private
|
||||||
@ -2114,7 +2125,6 @@ PoolOptions.prototype.fromOptions = function fromOptions(options) {
|
|||||||
if (this.spv) {
|
if (this.spv) {
|
||||||
this.requiredServices |= common.services.BLOOM;
|
this.requiredServices |= common.services.BLOOM;
|
||||||
this.services &= ~common.services.NETWORK;
|
this.services &= ~common.services.NETWORK;
|
||||||
this.useCheckpoints = true;
|
|
||||||
this.noRelay = true;
|
this.noRelay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user