debugging.
This commit is contained in:
parent
7b14c3b72b
commit
90b3c16837
@ -627,6 +627,9 @@ Chain.prototype._checkInputs = function _checkInputs(block, prev, flags, callbac
|
|||||||
utils.debug('Block is using spent inputs: %s (tx: %s, output: %s)',
|
utils.debug('Block is using spent inputs: %s (tx: %s, output: %s)',
|
||||||
block.rhash, tx.rhash,
|
block.rhash, tx.rhash,
|
||||||
input.prevout.rhash + '/' + input.prevout.index);
|
input.prevout.rhash + '/' + input.prevout.index);
|
||||||
|
throw new Error('Spent inputs: '
|
||||||
|
+ utils._inspect(input, false)
|
||||||
|
+ JSON.stringify(input, null, 2));
|
||||||
return callback(null, false);
|
return callback(null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,6 +637,15 @@ Chain.prototype._checkInputs = function _checkInputs(block, prev, flags, callbac
|
|||||||
if (!tx.verify(j, true, flags)) {
|
if (!tx.verify(j, true, flags)) {
|
||||||
utils.debug('Block has invalid inputs: %s (%s/%d)',
|
utils.debug('Block has invalid inputs: %s (%s/%d)',
|
||||||
block.rhash, tx.rhash, j);
|
block.rhash, tx.rhash, j);
|
||||||
|
utils.debug('Signature Hash: %s', utils.toHex(tx.signatureHash(j, input.output.script, 'all')));
|
||||||
|
utils.debug(input);
|
||||||
|
utils.debug('raw: %s', utils.toHex(input.output.script._raw || []));
|
||||||
|
utils.debug('encoded: %s', utils.toHex(bcoin.script.encode(input.output.script)));
|
||||||
|
throw new Error('Bad inputs: '
|
||||||
|
+ utils._inspect(input, false)
|
||||||
|
+ JSON.stringify(input, null, 2)
|
||||||
|
+ '\n'
|
||||||
|
+ utils.toHex(tx.signatureHash(j, input.output.script, 'all')));
|
||||||
return callback(null, false);
|
return callback(null, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1005,6 +1017,7 @@ Chain.prototype.add = function add(initial, peer, callback) {
|
|||||||
self.orphan.bmap = {};
|
self.orphan.bmap = {};
|
||||||
self.orphan.count = 0;
|
self.orphan.count = 0;
|
||||||
self.orphan.size = 0;
|
self.orphan.size = 0;
|
||||||
|
utils.debug('Warning: 20mb of orphans cleared!');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code !== Chain.codes.okay) {
|
if (code !== Chain.codes.okay) {
|
||||||
|
|||||||
@ -709,9 +709,6 @@ Pool.prototype._handleBlock = function _handleBlock(block, peer, callback) {
|
|||||||
if (err)
|
if (err)
|
||||||
return done(err);
|
return done(err);
|
||||||
|
|
||||||
if (added)
|
|
||||||
self.emit('pool block', block, peer);
|
|
||||||
|
|
||||||
// Resolve orphan chain.
|
// Resolve orphan chain.
|
||||||
self.peers.load.loadBlocks(
|
self.peers.load.loadBlocks(
|
||||||
self.chain.getLocator(),
|
self.chain.getLocator(),
|
||||||
@ -744,10 +741,8 @@ Pool.prototype._handleBlock = function _handleBlock(block, peer, callback) {
|
|||||||
if (err)
|
if (err)
|
||||||
return done(err);
|
return done(err);
|
||||||
|
|
||||||
if (added) {
|
if (added)
|
||||||
self.emit('pool block', block, peer);
|
|
||||||
return done(null, true);
|
return done(null, true);
|
||||||
}
|
|
||||||
|
|
||||||
return done(null, false);
|
return done(null, false);
|
||||||
});
|
});
|
||||||
@ -765,11 +760,6 @@ Pool.prototype._addIndex = function _addIndex(block, peer, callback) {
|
|||||||
|
|
||||||
self.emit('chain-progress', self.chain.fillPercent(), peer);
|
self.emit('chain-progress', self.chain.fillPercent(), peer);
|
||||||
|
|
||||||
// if (peer._requesting && peer._requesting.hash === block.hash('hex')) {
|
|
||||||
// delete peer._requesting;
|
|
||||||
// self._nextBlock(peer);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (added > 0 && peer._requesting)
|
if (added > 0 && peer._requesting)
|
||||||
delete peer._requesting;
|
delete peer._requesting;
|
||||||
|
|
||||||
@ -1563,10 +1553,10 @@ Pool.prototype._request = function _request(peer, type, hash, options, cb) {
|
|||||||
|
|
||||||
// Block should be not in chain, or be requested
|
// Block should be not in chain, or be requested
|
||||||
// Do not use with headers-first
|
// Do not use with headers-first
|
||||||
if (!options.force && (type === 'block' || type === 'filtered')) {
|
// if (!options.force && (type === 'block' || type === 'filtered')) {
|
||||||
if (this.chain.has(hash))
|
// if (this.chain.has(hash))
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
item = new LoadRequest(this, peer, type, hash, cb);
|
item = new LoadRequest(this, peer, type, hash, cb);
|
||||||
|
|
||||||
@ -1629,7 +1619,7 @@ Pool.prototype._nextBlock = function _nextBlock(peer) {
|
|||||||
|
|
||||||
utils.debug(
|
utils.debug(
|
||||||
'Requesting block %s (%d/%d) from %s with getdata (height %d)',
|
'Requesting block %s (%d/%d) from %s with getdata (height %d)',
|
||||||
utils.revHex(item[0].hash),
|
utils.revHex(item[item.length - 1].hash),
|
||||||
peer._blockQueue.length,
|
peer._blockQueue.length,
|
||||||
this.request.active,
|
this.request.active,
|
||||||
peer.host,
|
peer.host,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user