chain logs.

This commit is contained in:
Christopher Jeffrey 2016-05-04 22:16:12 -07:00
parent 2619be3675
commit 4802f409ca
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 17 additions and 25 deletions

View File

@ -95,10 +95,6 @@ utils.inherits(Chain, EventEmitter);
Chain.prototype._init = function _init() { Chain.prototype._init = function _init() {
var self = this; var self = this;
function getHost() {
return 'unknown';
}
this.locker.on('purge', function(total, size) { this.locker.on('purge', function(total, size) {
bcoin.debug('Warning: %dmb of pending objects. Purging.', utils.mb(size)); bcoin.debug('Warning: %dmb of pending objects. Purging.', utils.mb(size));
}); });
@ -108,8 +104,8 @@ Chain.prototype._init = function _init() {
if (self.height < network.block.slowHeight) if (self.height < network.block.slowHeight)
return; return;
bcoin.debug('Block %s (%d) added to chain (%s)', bcoin.debug('Block %s (%d) added to chain',
utils.revHex(entry.hash), entry.height, getHost()); utils.revHex(entry.hash), entry.height);
}); });
this.on('competitor', function(block, entry) { this.on('competitor', function(block, entry) {
@ -117,7 +113,7 @@ Chain.prototype._init = function _init() {
+ ' tip-height=%d competitor-height=%d' + ' tip-height=%d competitor-height=%d'
+ ' tip-hash=%s competitor-hash=%s' + ' tip-hash=%s competitor-hash=%s'
+ ' tip-chainwork=%s competitor-chainwork=%s' + ' tip-chainwork=%s competitor-chainwork=%s'
+ ' chainwork-diff=%s (%s)', + ' chainwork-diff=%s',
entry.height, entry.height,
self.tip.height, self.tip.height,
entry.height, entry.height,
@ -125,18 +121,17 @@ Chain.prototype._init = function _init() {
utils.revHex(entry.hash), utils.revHex(entry.hash),
self.tip.chainwork.toString(), self.tip.chainwork.toString(),
entry.chainwork.toString(), entry.chainwork.toString(),
self.tip.chainwork.sub(entry.chainwork).toString(), self.tip.chainwork.sub(entry.chainwork).toString());
getHost());
}); });
this.on('resolved', function(block, entry) { this.on('resolved', function(block, entry) {
bcoin.debug('Orphan %s (%d) was resolved (%s)', bcoin.debug('Orphan %s (%d) was resolved.',
utils.revHex(entry.hash), entry.height, getHost()); utils.revHex(entry.hash), entry.height);
}); });
this.on('checkpoint', function(block, data) { this.on('checkpoint', function(block, data) {
bcoin.debug('Hit checkpoint block %s (%d) (%s)', bcoin.debug('Hit checkpoint block %s (%d).',
utils.revHex(data.checkpoint), data.height, getHost()); utils.revHex(data.checkpoint), data.height);
}); });
this.on('fork', function(block, data) { this.on('fork', function(block, data) {
@ -145,8 +140,7 @@ Chain.prototype._init = function _init() {
data.height, data.height,
utils.revHex(data.expected), utils.revHex(data.expected),
utils.revHex(data.received), utils.revHex(data.received),
data.checkpoint, data.checkpoint
getHost()
); );
if (data.checkpoint) if (data.checkpoint)
bcoin.debug('WARNING: Block failed a checkpoint.'); bcoin.debug('WARNING: Block failed a checkpoint.');
@ -154,27 +148,25 @@ Chain.prototype._init = function _init() {
this.on('invalid', function(block, data) { this.on('invalid', function(block, data) {
bcoin.debug( bcoin.debug(
'Invalid block at height %d: hash=%s (%s)', 'Invalid block at height %d: hash=%s',
data.height, data.height,
utils.revHex(data.hash), utils.revHex(data.hash)
getHost()
); );
if (data.chain) { if (data.chain) {
bcoin.debug( bcoin.debug(
'Peer is sending an invalid continuation chain (%s)', 'Peer is sending an invalid continuation chain.');
getHost());
} else if (data.seen) { } else if (data.seen) {
bcoin.debug('Peer is sending an invalid chain (%s)', getHost()); bcoin.debug('Peer is sending an invalid chain.');
} }
}); });
this.on('exists', function(block, data) { this.on('exists', function(block, data) {
bcoin.debug('Already have block %s (%s)', bcoin.debug('Already have block %s (%d).',
data.height, getHost()); utils.revHex(data.hash), data.height);
}); });
this.on('orphan', function(block, data) { this.on('orphan', function(block, data) {
bcoin.debug('Handled orphan %s (%s)', utils.revHex(data.hash), getHost()); bcoin.debug('Handled orphan %s.', utils.revHex(data.hash));
}); });
this.on('purge', function(count, size) { this.on('purge', function(count, size) {

View File

@ -623,7 +623,7 @@ Mempool.prototype.addUnchecked = function addUnchecked(tx, callback) {
self.verify(tx, function(err) { self.verify(tx, function(err) {
if (err) { if (err) {
if (err.type === 'VerifyError') { if (err.type === 'VerifyError') {
bcoin.debug('Could not resolved orphan %s: %s.', bcoin.debug('Could not resolve orphan %s: %s.',
tx.rhash, tx.rhash,
err.message); err.message);
return next(); return next();