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() {
var self = this;
function getHost() {
return 'unknown';
}
this.locker.on('purge', function(total, 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)
return;
bcoin.debug('Block %s (%d) added to chain (%s)',
utils.revHex(entry.hash), entry.height, getHost());
bcoin.debug('Block %s (%d) added to chain',
utils.revHex(entry.hash), entry.height);
});
this.on('competitor', function(block, entry) {
@ -117,7 +113,7 @@ Chain.prototype._init = function _init() {
+ ' tip-height=%d competitor-height=%d'
+ ' tip-hash=%s competitor-hash=%s'
+ ' tip-chainwork=%s competitor-chainwork=%s'
+ ' chainwork-diff=%s (%s)',
+ ' chainwork-diff=%s',
entry.height,
self.tip.height,
entry.height,
@ -125,18 +121,17 @@ Chain.prototype._init = function _init() {
utils.revHex(entry.hash),
self.tip.chainwork.toString(),
entry.chainwork.toString(),
self.tip.chainwork.sub(entry.chainwork).toString(),
getHost());
self.tip.chainwork.sub(entry.chainwork).toString());
});
this.on('resolved', function(block, entry) {
bcoin.debug('Orphan %s (%d) was resolved (%s)',
utils.revHex(entry.hash), entry.height, getHost());
bcoin.debug('Orphan %s (%d) was resolved.',
utils.revHex(entry.hash), entry.height);
});
this.on('checkpoint', function(block, data) {
bcoin.debug('Hit checkpoint block %s (%d) (%s)',
utils.revHex(data.checkpoint), data.height, getHost());
bcoin.debug('Hit checkpoint block %s (%d).',
utils.revHex(data.checkpoint), data.height);
});
this.on('fork', function(block, data) {
@ -145,8 +140,7 @@ Chain.prototype._init = function _init() {
data.height,
utils.revHex(data.expected),
utils.revHex(data.received),
data.checkpoint,
getHost()
data.checkpoint
);
if (data.checkpoint)
bcoin.debug('WARNING: Block failed a checkpoint.');
@ -154,27 +148,25 @@ Chain.prototype._init = function _init() {
this.on('invalid', function(block, data) {
bcoin.debug(
'Invalid block at height %d: hash=%s (%s)',
'Invalid block at height %d: hash=%s',
data.height,
utils.revHex(data.hash),
getHost()
utils.revHex(data.hash)
);
if (data.chain) {
bcoin.debug(
'Peer is sending an invalid continuation chain (%s)',
getHost());
'Peer is sending an invalid continuation chain.');
} 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) {
bcoin.debug('Already have block %s (%s)',
data.height, getHost());
bcoin.debug('Already have block %s (%d).',
utils.revHex(data.hash), data.height);
});
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) {

View File

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