bcoin: update logger usage.

This commit is contained in:
Christopher Jeffrey 2018-08-10 06:36:16 -07:00
parent 5b56323310
commit a0ac953079
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
12 changed files with 147 additions and 153 deletions

View File

@ -889,10 +889,10 @@ class Chain extends AsyncEmitter {
} }
this.logger.warning( this.logger.warning(
'Chain reorganization: old=%s(%d) new=%s(%d)', 'Chain reorganization: old=%h(%d) new=%h(%d)',
tip.rhash(), tip.hash,
tip.height, tip.height,
competitor.rhash(), competitor.hash,
competitor.height competitor.height
); );
@ -937,10 +937,10 @@ class Chain extends AsyncEmitter {
} }
this.logger.warning( this.logger.warning(
'SPV reorganization: old=%s(%d) new=%s(%d)', 'SPV reorganization: old=%h(%d) new=%h(%d)',
tip.rhash(), tip.hash,
tip.height, tip.height,
competitor.rhash(), competitor.hash,
competitor.height competitor.height
); );
@ -1011,8 +1011,8 @@ class Chain extends AsyncEmitter {
if (!err.malleated) if (!err.malleated)
this.setInvalid(entry.hash); this.setInvalid(entry.hash);
this.logger.warning( this.logger.warning(
'Tried to reconnect invalid block: %s (%d).', 'Tried to reconnect invalid block: %h (%d).',
entry.rhash(), entry.height); entry.hash, entry.height);
} }
throw err; throw err;
} }
@ -1075,8 +1075,8 @@ class Chain extends AsyncEmitter {
if (!err.malleated) if (!err.malleated)
this.setInvalid(entry.hash); this.setInvalid(entry.hash);
this.logger.warning( this.logger.warning(
'Tried to connect invalid block: %s (%d).', 'Tried to connect invalid block: %h (%d).',
entry.rhash(), entry.height); entry.hash, entry.height);
} }
throw err; throw err;
} }
@ -1115,8 +1115,8 @@ class Chain extends AsyncEmitter {
if (!err.malleated) if (!err.malleated)
this.setInvalid(entry.hash); this.setInvalid(entry.hash);
this.logger.warning( this.logger.warning(
'Invalid block on alternate chain: %s (%d).', 'Invalid block on alternate chain: %h (%d).',
entry.rhash(), entry.height); entry.hash, entry.height);
} }
throw err; throw err;
} }
@ -1132,14 +1132,14 @@ class Chain extends AsyncEmitter {
this.logger.warning('Heads up: Competing chain at height %d:' this.logger.warning('Heads up: Competing chain at height %d:'
+ ' tip-height=%d competitor-height=%d' + ' tip-height=%d competitor-height=%d'
+ ' tip-hash=%s competitor-hash=%s' + ' tip-hash=%h competitor-hash=%h'
+ ' tip-chainwork=%s competitor-chainwork=%s' + ' tip-chainwork=%s competitor-chainwork=%s'
+ ' chainwork-diff=%s', + ' chainwork-diff=%s',
entry.height, entry.height,
this.tip.height, this.tip.height,
entry.height, entry.height,
this.tip.rhash(), this.tip.hash,
entry.rhash(), entry.hash,
this.tip.chainwork.toString(), this.tip.chainwork.toString(),
entry.chainwork.toString(), entry.chainwork.toString(),
this.tip.chainwork.sub(entry.chainwork).toString()); this.tip.chainwork.sub(entry.chainwork).toString());
@ -1333,26 +1333,26 @@ class Chain extends AsyncEmitter {
// Special case for genesis block. // Special case for genesis block.
if (hash.equals(this.network.genesis.hash)) { if (hash.equals(this.network.genesis.hash)) {
this.logger.debug('Saw genesis block: %s.', block.rhash()); this.logger.debug('Saw genesis block: %h.', block.hash());
throw new VerifyError(block, 'duplicate', 'duplicate', 0); throw new VerifyError(block, 'duplicate', 'duplicate', 0);
} }
// Do we already have this block in the queue? // Do we already have this block in the queue?
if (this.hasPending(hash)) { if (this.hasPending(hash)) {
this.logger.debug('Already have pending block: %s.', block.rhash()); this.logger.debug('Already have pending block: %h.', block.hash());
throw new VerifyError(block, 'duplicate', 'duplicate', 0); throw new VerifyError(block, 'duplicate', 'duplicate', 0);
} }
// If the block is already known to be // If the block is already known to be
// an orphan, ignore it. // an orphan, ignore it.
if (this.hasOrphan(hash)) { if (this.hasOrphan(hash)) {
this.logger.debug('Already have orphan block: %s.', block.rhash()); this.logger.debug('Already have orphan block: %h.', block.hash());
throw new VerifyError(block, 'duplicate', 'duplicate', 0); throw new VerifyError(block, 'duplicate', 'duplicate', 0);
} }
// Do not revalidate known invalid blocks. // Do not revalidate known invalid blocks.
if (this.hasInvalid(block)) { if (this.hasInvalid(block)) {
this.logger.debug('Invalid ancestors for block: %s.', block.rhash()); this.logger.debug('Invalid ancestors for block: %h.', block.hash());
throw new VerifyError(block, 'duplicate', 'duplicate', 100); throw new VerifyError(block, 'duplicate', 'duplicate', 100);
} }
@ -1364,7 +1364,7 @@ class Chain extends AsyncEmitter {
// Do we already have this block? // Do we already have this block?
if (await this.hasEntry(hash)) { if (await this.hasEntry(hash)) {
this.logger.debug('Already have block: %s.', block.rhash()); this.logger.debug('Already have block: %h.', block.hash());
throw new VerifyError(block, 'duplicate', 'duplicate', 0); throw new VerifyError(block, 'duplicate', 'duplicate', 0);
} }
@ -1468,8 +1468,8 @@ class Chain extends AsyncEmitter {
} catch (err) { } catch (err) {
if (err.type === 'VerifyError') { if (err.type === 'VerifyError') {
this.logger.warning( this.logger.warning(
'Could not resolve orphan block %s: %s.', 'Could not resolve orphan block %h: %s.',
block.rhash(), err.message); block.hash(), err.message);
this.emit('bad orphan', err, id); this.emit('bad orphan', err, id);
@ -1479,8 +1479,8 @@ class Chain extends AsyncEmitter {
} }
this.logger.debug( this.logger.debug(
'Orphan block was resolved: %s (%d).', 'Orphan block was resolved: %h (%d).',
block.rhash(), entry.height); block.hash(), entry.height);
this.emit('resolved', block, entry); this.emit('resolved', block, entry);
@ -1529,8 +1529,8 @@ class Chain extends AsyncEmitter {
const elapsed = util.bench(start); const elapsed = util.bench(start);
this.logger.info( this.logger.info(
'Block %s (%d) added to chain (size=%d txs=%d time=%d).', 'Block %h (%d) added to chain (size=%d txs=%d time=%d).',
entry.rhash(), entry.hash,
entry.height, entry.height,
block.getSize(), block.getSize(),
block.txs.length, block.txs.length,
@ -1561,8 +1561,8 @@ class Chain extends AsyncEmitter {
return true; return true;
if (hash.equals(checkpoint)) { if (hash.equals(checkpoint)) {
this.logger.debug('Hit checkpoint block %s (%d).', this.logger.debug('Hit checkpoint block %h (%d).',
util.revHex(hash), height); hash, height);
this.emit('checkpoint', hash, height); this.emit('checkpoint', hash, height);
return true; return true;
} }
@ -1572,10 +1572,10 @@ class Chain extends AsyncEmitter {
// consensus protocol is broken and // consensus protocol is broken and
// there was a 20k+ block reorg. // there was a 20k+ block reorg.
this.logger.warning( this.logger.warning(
'Checkpoint mismatch at height %d: expected=%s received=%s', 'Checkpoint mismatch at height %d: expected=%h received=%h',
height, height,
util.revHex(checkpoint), checkpoint,
util.revHex(hash) hash
); );
this.purgeOrphans(); this.purgeOrphans();
@ -1601,8 +1601,8 @@ class Chain extends AsyncEmitter {
assert(orphan.block.prevBlock.equals(block.prevBlock)); assert(orphan.block.prevBlock.equals(block.prevBlock));
this.logger.warning( this.logger.warning(
'Removing forked orphan block: %s (%d).', 'Removing forked orphan block: %h (%d).',
orphan.block.rhash(), height); orphan.block.hash(), height);
this.removeOrphan(orphan); this.removeOrphan(orphan);
} }
@ -1611,8 +1611,8 @@ class Chain extends AsyncEmitter {
this.addOrphan(new Orphan(block, flags, id)); this.addOrphan(new Orphan(block, flags, id));
this.logger.debug( this.logger.debug(
'Storing orphan block: %s (%d).', 'Storing orphan block: %h (%d).',
block.rhash(), height); block.hash(), height);
this.emit('orphan', block); this.emit('orphan', block);
} }

View File

@ -91,8 +91,8 @@ class ChainDB {
} }
this.logger.info( this.logger.info(
'Chain State: hash=%s tx=%d coin=%d value=%s.', 'Chain State: hash=%h tx=%d coin=%d value=%s.',
this.state.rhash(), this.state.tip,
this.state.tx, this.state.tx,
this.state.coin, this.state.coin,
Amount.btc(this.state.value)); Amount.btc(this.state.value));
@ -1265,7 +1265,7 @@ class ChainDB {
if (typeof start === 'number') if (typeof start === 'number')
this.logger.info('Scanning from height %d.', start); this.logger.info('Scanning from height %d.', start);
else else
this.logger.info('Scanning from block %s.', util.revHex(start)); this.logger.info('Scanning from block %h.', start);
let entry = await this.getEntry(start); let entry = await this.getEntry(start);
@ -1292,8 +1292,8 @@ class ChainDB {
} }
this.logger.info( this.logger.info(
'Scanning block %s (%d).', 'Scanning block %h (%d).',
entry.rhash(), entry.height); entry.hash, entry.height);
for (let i = 0; i < block.txs.length; i++) { for (let i = 0; i < block.txs.length; i++) {
const tx = block.txs[i]; const tx = block.txs[i];
@ -1558,7 +1558,7 @@ class ChainDB {
let tip = await this.getTip(); let tip = await this.getTip();
assert(tip); assert(tip);
this.logger.debug('Resetting main chain to: %s', entry.rhash()); this.logger.debug('Resetting main chain to: %h', entry.hash);
for (;;) { for (;;) {
this.start(); this.start();
@ -1643,7 +1643,7 @@ class ChainDB {
if (!tip) if (!tip)
throw new Error('Alternate chain tip not found.'); throw new Error('Alternate chain tip not found.');
this.logger.debug('Removing alternate chain: %s.', tip.rhash()); this.logger.debug('Removing alternate chain: %h.', tip.hash);
for (;;) { for (;;) {
if (await this.isMainChain(tip)) if (await this.isMainChain(tip))
@ -2128,10 +2128,6 @@ class ChainState {
this.committed = false; this.committed = false;
} }
rhash() {
return util.revHex(this.tip);
}
clone() { clone() {
const state = new ChainState(); const state = new ChainState();
state.tip = this.tip; state.tip = this.tip;

View File

@ -490,7 +490,7 @@ class PolicyEstimator {
const item = this.map.get(hash); const item = this.map.get(hash);
if (!item) { if (!item) {
this.logger.spam('Mempool tx %s not found.', util.revHex(hash)); this.logger.spam('Mempool tx %h not found.', hash);
return; return;
} }
@ -540,7 +540,7 @@ class PolicyEstimator {
const hash = entry.hash(); const hash = entry.hash();
if (this.map.has(hash)) { if (this.map.has(hash)) {
this.logger.debug('Mempool tx %s already tracked.', entry.txid()); this.logger.debug('Mempool tx %h already tracked.', entry.hash());
return; return;
} }
@ -560,7 +560,7 @@ class PolicyEstimator {
const rate = entry.getRate(); const rate = entry.getRate();
const priority = entry.getPriority(height); const priority = entry.getPriority(height);
this.logger.spam('Processing mempool tx %s.', entry.txid()); this.logger.spam('Processing mempool tx %h.', entry.hash());
if (fee === 0 || this.isPriPoint(rate, priority)) { if (fee === 0 || this.isPriPoint(rate, priority)) {
const item = new StatEntry(); const item = new StatEntry();
@ -573,7 +573,7 @@ class PolicyEstimator {
item.bucketIndex = this.feeStats.addTX(height, rate); item.bucketIndex = this.feeStats.addTX(height, rate);
this.map.set(hash, item); this.map.set(hash, item);
} else { } else {
this.logger.spam('Not adding tx %s.', entry.txid()); this.logger.spam('Not adding tx %h.', entry.hash());
} }
} }
@ -592,8 +592,8 @@ class PolicyEstimator {
if (blocks <= 0) { if (blocks <= 0) {
this.logger.debug( this.logger.debug(
'Block tx %s had negative blocks to confirm (%d, %d).', 'Block tx %h had negative blocks to confirm (%d, %d).',
entry.txid(), entry.hash(),
height, height,
entry.height); entry.height);
return; return;

View File

@ -413,8 +413,8 @@ class Mempool extends EventEmitter {
} }
this.logger.debug( this.logger.debug(
'Removing package %s from mempool (too old).', 'Removing package %h from mempool (too old).',
entry.txid()); entry.hash());
this.evictEntry(entry); this.evictEntry(entry);
} }
@ -439,8 +439,8 @@ class Mempool extends EventEmitter {
assert(this.hasEntry(hash)); assert(this.hasEntry(hash));
this.logger.debug( this.logger.debug(
'Removing package %s from mempool (low fee).', 'Removing package %h from mempool (low fee).',
entry.txid()); entry.hash());
this.evictEntry(entry); this.evictEntry(entry);
@ -1096,8 +1096,8 @@ class Mempool extends EventEmitter {
this.fees.processTX(entry, this.chain.synced); this.fees.processTX(entry, this.chain.synced);
this.logger.debug( this.logger.debug(
'Added %s to mempool (txs=%d).', 'Added %h to mempool (txs=%d).',
tx.txid(), this.map.size); tx.hash(), this.map.size);
this.cache.save(entry); this.cache.save(entry);
@ -1451,16 +1451,16 @@ class Mempool extends EventEmitter {
if (this.hasReject(prevout.hash)) { if (this.hasReject(prevout.hash)) {
this.logger.debug( this.logger.debug(
'Not storing orphan %s (rejected parents).', 'Not storing orphan %h (rejected parents).',
tx.txid()); tx.hash());
this.rejects.add(tx.hash()); this.rejects.add(tx.hash());
return missing; return missing;
} }
if (this.hasEntry(prevout.hash)) { if (this.hasEntry(prevout.hash)) {
this.logger.debug( this.logger.debug(
'Not storing orphan %s (non-existent output).', 'Not storing orphan %h (non-existent output).',
tx.txid()); tx.hash());
this.rejects.add(tx.hash()); this.rejects.add(tx.hash());
return missing; return missing;
} }
@ -1474,7 +1474,7 @@ class Mempool extends EventEmitter {
// Weight limit for orphans. // Weight limit for orphans.
if (tx.getWeight() > policy.MAX_TX_WEIGHT) { if (tx.getWeight() > policy.MAX_TX_WEIGHT) {
this.logger.debug('Ignoring large orphan: %s', tx.txid()); this.logger.debug('Ignoring large orphan: %h', tx.hash());
if (!tx.hasWitness()) if (!tx.hasWitness())
this.rejects.add(tx.hash()); this.rejects.add(tx.hash());
return missing; return missing;
@ -1498,7 +1498,7 @@ class Mempool extends EventEmitter {
this.orphans.set(hash, new Orphan(tx, missing.length, id)); this.orphans.set(hash, new Orphan(tx, missing.length, id));
this.logger.debug('Added orphan %s to mempool.', tx.txid()); this.logger.debug('Added orphan %h to mempool.', tx.hash());
this.emit('add orphan', tx); this.emit('add orphan', tx);
@ -1532,8 +1532,8 @@ class Mempool extends EventEmitter {
} catch (err) { } catch (err) {
if (err.type === 'VerifyError') { if (err.type === 'VerifyError') {
this.logger.debug( this.logger.debug(
'Could not resolve orphan %s: %s.', 'Could not resolve orphan %h: %s.',
tx.txid(), err.message); tx.hash(), err.message);
if (!tx.hasWitness() && !err.malleated) if (!tx.hasWitness() && !err.malleated)
this.rejects.add(tx.hash()); this.rejects.add(tx.hash());
@ -1550,13 +1550,13 @@ class Mempool extends EventEmitter {
// the non-present parents. // the non-present parents.
if (missing && missing.length > 0) { if (missing && missing.length > 0) {
this.logger.debug( this.logger.debug(
'Transaction %s was double-orphaned in mempool.', 'Transaction %h was double-orphaned in mempool.',
tx.txid()); tx.hash());
this.removeOrphan(tx.hash()); this.removeOrphan(tx.hash());
continue; continue;
} }
this.logger.debug('Resolved orphan %s in mempool.', tx.txid()); this.logger.debug('Resolved orphan %h in mempool.', tx.hash());
} }
} }
@ -1660,8 +1660,7 @@ class Mempool extends EventEmitter {
assert(hash); assert(hash);
this.logger.debug('Removing orphan %s from mempool.', this.logger.debug('Removing orphan %h from mempool.', hash);
util.revHex(hash));
this.removeOrphan(hash); this.removeOrphan(hash);
@ -1887,8 +1886,8 @@ class Mempool extends EventEmitter {
continue; continue;
this.logger.debug( this.logger.debug(
'Removing double spender from mempool: %s.', 'Removing double spender from mempool: %h.',
spent.txid()); spent.hash());
this.evictEntry(spent); this.evictEntry(spent);
@ -2514,8 +2513,8 @@ class MempoolCache {
tip = this.chain.tip.hash; tip = this.chain.tip.hash;
this.logger.info( this.logger.info(
'Mempool cache is empty. Writing tip %s.', 'Mempool cache is empty. Writing tip %h.',
util.revHex(tip)); tip);
await this.init(tip); await this.init(tip);
} }
@ -2534,9 +2533,9 @@ class MempoolCache {
if (!tip || !tip.equals(this.chain.tip.hash)) { if (!tip || !tip.equals(this.chain.tip.hash)) {
this.logger.warning( this.logger.warning(
'Mempool tip not consistent with chain tip (%s != %s)!', 'Mempool tip not consistent with chain tip (%h != %h)!',
util.revHex(tip), tip,
this.chain.tip.rhash()); this.chain.tip.hash);
this.logger.warning('Invalidating mempool cache.'); this.logger.warning('Invalidating mempool cache.');
await this.wipe(); await this.wipe();
return false; return false;

View File

@ -160,8 +160,7 @@ class CPUMiner extends EventEmitter {
break; break;
// Log the block hex as a failsafe (in case we can't send it). // Log the block hex as a failsafe (in case we can't send it).
this.logger.info('Found block: %d (%s).', entry.height, entry.rhash()); this.logger.info('Found block: %d (%h).', entry.height, entry.hash);
this.logger.debug('Raw: %s', block.toRaw().toString('hex'));
this.emit('block', block, entry); this.emit('block', block, entry);
} }
@ -401,12 +400,12 @@ class CPUMiner extends EventEmitter {
sendStatus(job, nonce) { sendStatus(job, nonce) {
const attempt = job.attempt; const attempt = job.attempt;
const tip = util.revHex(attempt.prevBlock); const tip = attempt.prevBlock;
const hashes = job.getHashes(nonce); const hashes = job.getHashes(nonce);
const hashrate = job.getRate(nonce); const hashrate = job.getRate(nonce);
this.logger.info( this.logger.info(
'Status: hashrate=%dkhs hashes=%d target=%d height=%d tip=%s', 'Status: hashrate=%dkhs hashes=%d target=%d height=%d tip=%h',
Math.floor(hashrate / 1000), Math.floor(hashrate / 1000),
hashes, hashes,
attempt.bits, attempt.bits,

View File

@ -1684,18 +1684,18 @@ class Peer extends EventEmitter {
let hash = null; let hash = null;
if (packet.locator.length > 0) if (packet.locator.length > 0)
hash = util.revHex(packet.locator[0]); hash = packet.locator[0];
let end = null; let end = null;
if (stop) if (stop)
end = util.revHex(stop); end = stop;
this.logger.debug( this.logger.debug(
'Requesting headers packet from peer with getheaders (%s).', 'Requesting headers packet from peer with getheaders (%s).',
this.hostname()); this.hostname());
this.logger.debug( this.logger.debug(
'Sending getheaders (hash=%s, stop=%s).', 'Sending getheaders (hash=%h, stop=%h).',
hash, end); hash, end);
this.send(packet); this.send(packet);
@ -1712,18 +1712,18 @@ class Peer extends EventEmitter {
let hash = null; let hash = null;
if (packet.locator.length > 0) if (packet.locator.length > 0)
hash = util.revHex(packet.locator[0]); hash = packet.locator[0];
let end = null; let end = null;
if (stop) if (stop)
end = util.revHex(stop); end = stop;
this.logger.debug( this.logger.debug(
'Requesting inv packet from peer with getblocks (%s).', 'Requesting inv packet from peer with getblocks (%s).',
this.hostname()); this.hostname());
this.logger.debug( this.logger.debug(
'Sending getblocks (hash=%s, stop=%s).', 'Sending getblocks (hash=%h, stop=%h).',
hash, end); hash, end);
this.send(packet); this.send(packet);
@ -1763,8 +1763,8 @@ class Peer extends EventEmitter {
const reject = packets.RejectPacket.fromReason(code, reason, msg, hash); const reject = packets.RejectPacket.fromReason(code, reason, msg, hash);
if (msg) { if (msg) {
this.logger.debug('Rejecting %s %s (%s): code=%s reason=%s.', this.logger.debug('Rejecting %s %h (%s): code=%s reason=%s.',
msg, util.revHex(hash), this.hostname(), code, reason); msg, hash, this.hostname(), code, reason);
} else { } else {
this.logger.debug('Rejecting packet from %s: code=%s reason=%s.', this.logger.debug('Rejecting packet from %s: code=%s reason=%s.',
this.hostname(), code, reason); this.hostname(), code, reason);

View File

@ -219,8 +219,8 @@ class Pool extends EventEmitter {
this.headerTip = this.getNextTip(tip.height); this.headerTip = this.getNextTip(tip.height);
this.headerChain.push(new HeaderEntry(tip.hash, tip.height)); this.headerChain.push(new HeaderEntry(tip.hash, tip.height));
this.logger.info( this.logger.info(
'Initialized header chain to height %d (checkpoint=%s).', 'Initialized header chain to height %d (checkpoint=%h).',
tip.height, util.revHex(this.headerTip.hash)); tip.height, this.headerTip.hash);
} }
} }
@ -954,9 +954,9 @@ class Pool extends EventEmitter {
} }
this.logger.debug( this.logger.debug(
'Peer requested %s %s as a %s packet (%s).', 'Peer requested %s %h as a %s packet (%s).',
item.isTX() ? 'tx' : 'block', item.isTX() ? 'tx' : 'block',
item.rhash(), item.hash(),
item.hasWitness() ? 'witness' : 'normal', item.hasWitness() ? 'witness' : 'normal',
peer.hostname()); peer.hostname());
@ -1620,7 +1620,7 @@ class Pool extends EventEmitter {
return; return;
this.logger.debug( this.logger.debug(
'Received %s block hashes from peer (%s).', 'Received %d block hashes from peer (%s).',
hashes.length, hashes.length,
peer.hostname()); peer.hostname());
@ -1853,7 +1853,7 @@ class Pool extends EventEmitter {
if (unknown !== -1) { if (unknown !== -1) {
this.logger.warning( this.logger.warning(
'Peer sent an unknown getdata type: %s (%d).', 'Peer sent an unknown getdata type: %d (%s).',
unknown, peer.hostname()); unknown, peer.hostname());
} }
} }
@ -1872,7 +1872,7 @@ class Pool extends EventEmitter {
for (const item of items) { for (const item of items) {
if (!this.resolveItem(peer, item)) { if (!this.resolveItem(peer, item)) {
this.logger.warning( this.logger.warning(
'Peer sent notfound for unrequested item: %s (%s).', 'Peer sent notfound for unrequested item: %h (%s).',
item.hash, peer.hostname()); item.hash, peer.hostname());
peer.destroy(); peer.destroy();
return; return;
@ -2071,7 +2071,7 @@ class Pool extends EventEmitter {
} }
this.logger.debug( this.logger.debug(
'Received %s headers from peer (%s).', 'Received %d headers from peer (%s).',
headers.length, headers.length,
peer.hostname()); peer.hostname());
@ -2161,8 +2161,8 @@ class Pool extends EventEmitter {
if (!this.resolveBlock(peer, hash)) { if (!this.resolveBlock(peer, hash)) {
this.logger.warning( this.logger.warning(
'Received unrequested block: %s (%s).', 'Received unrequested block: %h (%s).',
block.rhash(), peer.hostname()); block.hash(), peer.hostname());
peer.destroy(); peer.destroy();
return; return;
} }
@ -2244,9 +2244,9 @@ class Pool extends EventEmitter {
if (!hash.equals(node.hash)) { if (!hash.equals(node.hash)) {
this.logger.warning( this.logger.warning(
'Header hash mismatch %s != %s (%s).', 'Header hash mismatch %h != %h (%s).',
util.revHex(hash), hash,
util.revHex(node.hash), node.hash,
peer.hostname()); peer.hostname());
peer.destroy(); peer.destroy();
@ -2257,8 +2257,8 @@ class Pool extends EventEmitter {
if (node.height < this.network.lastCheckpoint) { if (node.height < this.network.lastCheckpoint) {
if (node.height === this.headerTip.height) { if (node.height === this.headerTip.height) {
this.logger.info( this.logger.info(
'Received checkpoint %s (%d).', 'Received checkpoint %h (%d).',
util.revHex(node.hash), node.height); node.hash, node.height);
this.headerTip = this.getNextTip(node.height); this.headerTip = this.getNextTip(node.height);
@ -2314,8 +2314,8 @@ class Pool extends EventEmitter {
if (!peer) { if (!peer) {
this.logger.warning( this.logger.warning(
'Could not find offending peer for orphan: %s (%d).', 'Could not find offending peer for orphan: %h (%d).',
util.revHex(err.hash), id); err.hash, id);
return; return;
} }
@ -2350,9 +2350,9 @@ class Pool extends EventEmitter {
if (this.chain.height % 2000 === 0) { if (this.chain.height % 2000 === 0) {
this.logger.info( this.logger.info(
'Received 2000 more blocks (height=%d, hash=%s).', 'Received 2000 more blocks (height=%d, hash=%h).',
this.chain.height, this.chain.height,
block.rhash()); block.hash());
} }
} }
@ -2397,8 +2397,8 @@ class Pool extends EventEmitter {
if (block.hasTX(hash)) { if (block.hasTX(hash)) {
if (peer.merkleMap.has(hash)) { if (peer.merkleMap.has(hash)) {
this.logger.warning( this.logger.warning(
'Peer sent duplicate merkle tx: %s (%s).', 'Peer sent duplicate merkle tx: %h (%s).',
tx.txid(), peer.hostname()); tx.hash(), peer.hostname());
peer.increaseBan(100); peer.increaseBan(100);
return; return;
} }
@ -2421,8 +2421,8 @@ class Pool extends EventEmitter {
if (!this.resolveTX(peer, hash)) { if (!this.resolveTX(peer, hash)) {
this.logger.warning( this.logger.warning(
'Peer sent unrequested tx: %s (%s).', 'Peer sent unrequested tx: %h (%s).',
tx.txid(), peer.hostname()); tx.hash(), peer.hostname());
peer.destroy(); peer.destroy();
return; return;
} }
@ -2463,12 +2463,12 @@ class Pool extends EventEmitter {
async handleReject(peer, packet) { async handleReject(peer, packet) {
this.logger.warning( this.logger.warning(
'Received reject (%s): msg=%s code=%s reason=%s hash=%s.', 'Received reject (%s): msg=%s code=%s reason=%s hash=%h.',
peer.hostname(), peer.hostname(),
packet.message, packet.message,
packet.getCode(), packet.getCode(),
packet.reason, packet.reason,
packet.rhash()); packet.hash);
if (!packet.hash) if (!packet.hash)
return; return;
@ -2700,7 +2700,7 @@ class Pool extends EventEmitter {
if (this.compactBlocks.has(hash)) { if (this.compactBlocks.has(hash)) {
this.logger.debug( this.logger.debug(
'Already waiting for compact block %s (%s).', 'Already waiting for compact block %h (%s).',
hash, peer.hostname()); hash, peer.hostname());
return; return;
} }
@ -2744,8 +2744,8 @@ class Pool extends EventEmitter {
if (!result) { if (!result) {
this.logger.warning( this.logger.warning(
'Siphash collision for %s. Requesting full block (%s).', 'Siphash collision for %h. Requesting full block (%s).',
block.rhash(), peer.hostname()); block.hash(), peer.hostname());
peer.getFullBlock(hash); peer.getFullBlock(hash);
peer.increaseBan(10); peer.increaseBan(10);
return; return;
@ -2755,8 +2755,8 @@ class Pool extends EventEmitter {
if (full) { if (full) {
this.logger.debug( this.logger.debug(
'Received full compact block %s (%s).', 'Received full compact block %h (%s).',
block.rhash(), peer.hostname()); block.hash(), peer.hostname());
const flags = chainCommon.flags.VERIFY_BODY; const flags = chainCommon.flags.VERIFY_BODY;
await this.addBlock(peer, block.toBlock(), flags); await this.addBlock(peer, block.toBlock(), flags);
return; return;
@ -2776,8 +2776,8 @@ class Pool extends EventEmitter {
this.compactBlocks.add(hash); this.compactBlocks.add(hash);
this.logger.debug( this.logger.debug(
'Received non-full compact block %s tx=%d/%d (%s).', 'Received non-full compact block %h tx=%d/%d (%s).',
block.rhash(), block.count, block.totalTX, peer.hostname()); block.hash(), block.count, block.totalTX, peer.hostname());
peer.send(new packets.GetBlockTxnPacket(block.toRequest())); peer.send(new packets.GetBlockTxnPacket(block.toRequest()));
} }
@ -2824,8 +2824,8 @@ class Pool extends EventEmitter {
} }
this.logger.debug( this.logger.debug(
'Sending blocktxn for %s to peer (%s).', 'Sending blocktxn for %h to peer (%s).',
block.rhash(), block.hash(),
peer.hostname()); peer.hostname());
const res = BIP152.TXResponse.fromBlock(block, req); const res = BIP152.TXResponse.fromBlock(block, req);
@ -2860,8 +2860,8 @@ class Pool extends EventEmitter {
if (!block.fillMissing(res)) { if (!block.fillMissing(res)) {
this.logger.warning( this.logger.warning(
'Peer sent non-full blocktxn for %s. Requesting full block (%s).', 'Peer sent non-full blocktxn for %h. Requesting full block (%s).',
block.rhash(), block.hash(),
peer.hostname()); peer.hostname());
peer.getFullBlock(res.hash); peer.getFullBlock(res.hash);
peer.increaseBan(10); peer.increaseBan(10);
@ -2869,8 +2869,8 @@ class Pool extends EventEmitter {
} }
this.logger.debug( this.logger.debug(
'Filled compact block %s (%s).', 'Filled compact block %h (%s).',
block.rhash(), peer.hostname()); block.hash(), peer.hostname());
await this.addBlock(peer, block.toBlock(), flags); await this.addBlock(peer, block.toBlock(), flags);
} }
@ -3358,7 +3358,7 @@ class Pool extends EventEmitter {
// If we recently rejected this item. Ignore. // If we recently rejected this item. Ignore.
if (this.mempool.hasReject(hash)) { if (this.mempool.hasReject(hash)) {
this.logger.spam('Saw known reject of %s.', util.revHex(hash)); this.logger.spam('Saw known reject of %h.', hash);
return true; return true;
} }
} }

View File

@ -298,7 +298,7 @@ class FullNode extends Node {
} catch (err) { } catch (err) {
if (err.type === 'VerifyError' && err.score === 0) { if (err.type === 'VerifyError' && err.score === 0) {
this.error(err); this.error(err);
this.logger.warning('Verification failed for tx: %s.', tx.txid()); this.logger.warning('Verification failed for tx: %h.', tx.hash());
this.logger.warning('Attempting to broadcast anyway...'); this.logger.warning('Attempting to broadcast anyway...');
this.broadcast(tx); this.broadcast(tx);
return; return;
@ -307,7 +307,7 @@ class FullNode extends Node {
} }
if (missing) { if (missing) {
this.logger.warning('TX was orphaned in mempool: %s.', tx.txid()); this.logger.warning('TX was orphaned in mempool: %h.', tx.hash());
this.logger.warning('Attempting to broadcast anyway...'); this.logger.warning('Attempting to broadcast anyway...');
this.broadcast(tx); this.broadcast(tx);
return; return;

View File

@ -1140,16 +1140,16 @@ class RPC extends RPCBase {
entry = await this.chain.add(block); entry = await this.chain.add(block);
} catch (err) { } catch (err) {
if (err.type === 'VerifyError') { if (err.type === 'VerifyError') {
this.logger.warning('RPC block rejected: %s (%s).', this.logger.warning('RPC block rejected: %h (%s).',
block.rhash(), err.reason); block.hash(), err.reason);
return false; return false;
} }
throw err; throw err;
} }
if (!entry) { if (!entry) {
this.logger.warning('RPC block rejected: %s (bad-prevblk).', this.logger.warning('RPC block rejected: %h (bad-prevblk).',
block.rhash()); block.hash());
return false; return false;
} }
@ -2414,7 +2414,7 @@ class RPC extends RPCBase {
} }
async _addBlock(block) { async _addBlock(block) {
this.logger.info('Handling submitted block: %s.', block.rhash()); this.logger.info('Handling submitted block: %h.', block.hash());
const prev = await this.chain.getEntry(block.prevBlock); const prev = await this.chain.getEntry(block.prevBlock);
@ -2444,16 +2444,16 @@ class RPC extends RPCBase {
entry = await this.chain._add(block); entry = await this.chain._add(block);
} catch (err) { } catch (err) {
if (err.type === 'VerifyError') { if (err.type === 'VerifyError') {
this.logger.warning('RPC block rejected: %s (%s).', this.logger.warning('RPC block rejected: %h (%s).',
block.rhash(), err.reason); block.hash(), err.reason);
return `rejected: ${err.reason}`; return `rejected: ${err.reason}`;
} }
throw err; throw err;
} }
if (!entry) { if (!entry) {
this.logger.warning('RPC block rejected: %s (bad-prevblk).', this.logger.warning('RPC block rejected: %h (bad-prevblk).',
block.rhash()); block.hash());
return 'rejected: bad-prevblk'; return 'rejected: bad-prevblk';
} }

View File

@ -1068,11 +1068,11 @@ class TXDB {
async removeConflict(wtx) { async removeConflict(wtx) {
const tx = wtx.tx; const tx = wtx.tx;
this.logger.warning('Handling conflicting tx: %s.', tx.txid()); this.logger.warning('Handling conflicting tx: %h.', tx.hash());
const details = await this.removeRecursive(wtx); const details = await this.removeRecursive(wtx);
this.logger.warning('Removed conflict: %s.', tx.txid()); this.logger.warning('Removed conflict: %h.', tx.hash());
// Emit the _removed_ transaction. // Emit the _removed_ transaction.
this.emit('conflict', tx, details); this.emit('conflict', tx, details);
@ -2022,8 +2022,8 @@ class TXDB {
assert(now - wtx.mtime >= age); assert(now - wtx.mtime >= age);
this.logger.debug('Zapping TX: %s (%d)', this.logger.debug('Zapping TX: %h (%d)',
wtx.tx.txid(), this.wid); wtx.tx.hash(), this.wid);
await this.remove(wtx.hash); await this.remove(wtx.hash);

View File

@ -1335,7 +1335,7 @@ class Wallet extends EventEmitter {
await this.wdb.addTX(tx); await this.wdb.addTX(tx);
this.logger.debug('Sending wallet tx (%s): %s', this.id, tx.txid()); this.logger.debug('Sending wallet tx (%s): %h', this.id, tx.hash());
await this.wdb.send(tx); await this.wdb.send(tx);
@ -1436,8 +1436,8 @@ class Wallet extends EventEmitter {
const ntx = mtx.toTX(); const ntx = mtx.toTX();
this.logger.debug( this.logger.debug(
'Increasing fee for wallet tx (%s): %s', 'Increasing fee for wallet tx (%s): %h',
this.id, ntx.txid()); this.id, ntx.hash());
await this.wdb.addTX(ntx); await this.wdb.addTX(ntx);
await this.wdb.send(ntx); await this.wdb.send(ntx);

View File

@ -1985,8 +1985,8 @@ class WalletDB extends EventEmitter {
} }
if (total > 0) { if (total > 0) {
this.logger.info('Connected WalletDB block %s (tx=%d).', this.logger.info('Connected WalletDB block %h (tx=%d).',
util.revHex(tip.hash), total); tip.hash, total);
} }
return total; return total;
@ -2053,8 +2053,8 @@ class WalletDB extends EventEmitter {
// Sync the state to the previous tip. // Sync the state to the previous tip.
await this.setTip(prev); await this.setTip(prev);
this.logger.warning('Disconnected wallet block %s (tx=%d).', this.logger.warning('Disconnected wallet block %h (tx=%d).',
util.revHex(tip.hash), total); tip.hash, total);
return total; return total;
} }
@ -2123,8 +2123,8 @@ class WalletDB extends EventEmitter {
await this.markState(block); await this.markState(block);
this.logger.info( this.logger.info(
'Incoming transaction for %d wallets in WalletDB (%s).', 'Incoming transaction for %d wallets in WalletDB (%h).',
wids.size, tx.txid()); wids.size, tx.hash());
let result = false; let result = false;