Fixed logging timing issue.

This commit is contained in:
Chris Kleeschulte 2017-10-07 15:22:28 -04:00
parent aa6570d23a
commit 0007848c07
No known key found for this signature in database
GPG Key ID: 33195D27EF6BDB7F

View File

@ -413,7 +413,7 @@ BlockService.prototype._queueBlock = function(block) {
return self._handleError(err); return self._handleError(err);
} }
self._logSynced(block.rhash()); self._logSynced(block.rhash(), true);
self._blocksInQueue--; self._blocksInQueue--;
}); });
@ -837,7 +837,7 @@ BlockService.prototype._setTip = function(tip, callback) {
this._saveTip(tip, callback); this._saveTip(tip, callback);
}; };
BlockService.prototype._logSynced = function(blockHash) { BlockService.prototype._logSynced = function(blockHash, noHeight) {
var self = this; var self = this;
@ -850,13 +850,18 @@ BlockService.prototype._logSynced = function(blockHash) {
async.waterfall([ async.waterfall([
function(next) { function(next) {
if (noHeight) {
next(null, null);
}
self._header.getBlockHeader(blockHash, function(err, header) { self._header.getBlockHeader(blockHash, function(err, header) {
if (err) { if (err) {
return next(err); return next(err);
} }
if (!header) { if (!header) {
return next(); return next(null, null);
} }
blockHeight = header.height; blockHeight = header.height;
@ -885,8 +890,13 @@ BlockService.prototype._logSynced = function(blockHash) {
return self._handleError(err); return self._handleError(err);
} }
var supplementals = '';
if (blockHeight && timeDiff) {
supplementals += blockHeight + '. Time between the last 2 blocks (adjusted): ' + timeDiff;
}
log.info('Block Service: The best block hash is: ' + blockHash + log.info('Block Service: The best block hash is: ' + blockHash +
' at height: ' + blockHeight + '. Time between the last 2 blocks (adjusted): ' + timeDiff); ' at height: ' + supplementals);
}); });