debugging.
This commit is contained in:
parent
2dc3786eb0
commit
7b14c3b72b
@ -118,8 +118,6 @@ Chain.prototype._init = function _init() {
|
||||
utils.debug('Chain successfully loaded.');
|
||||
}
|
||||
|
||||
// self.resetHeight(self.tip.height - 1);
|
||||
|
||||
if (!self.blockdb)
|
||||
return doneForReal();
|
||||
|
||||
@ -127,6 +125,8 @@ Chain.prototype._init = function _init() {
|
||||
if (err)
|
||||
throw err;
|
||||
|
||||
assert(height !== -1);
|
||||
|
||||
if (height === self.tip.height)
|
||||
return doneForReal();
|
||||
|
||||
@ -158,6 +158,9 @@ Chain.prototype._init = function _init() {
|
||||
if (lastEntry && entry.prevBlock !== lastEntry.hash)
|
||||
return done(Math.max(0, i - 2));
|
||||
|
||||
if (i % 10000 === 0)
|
||||
utils.debug('Loaded %d blocks.', i);
|
||||
|
||||
lastEntry = entry;
|
||||
self._saveEntry(entry);
|
||||
i += 1;
|
||||
@ -629,7 +632,8 @@ Chain.prototype._checkInputs = function _checkInputs(block, prev, flags, callbac
|
||||
|
||||
// Verify the scripts
|
||||
if (!tx.verify(j, true, flags)) {
|
||||
utils.debug('Block has invalid inputs: %s', block.rhash);
|
||||
utils.debug('Block has invalid inputs: %s (%s/%d)',
|
||||
block.rhash, tx.rhash, j);
|
||||
return callback(null, false);
|
||||
}
|
||||
}
|
||||
@ -825,7 +829,7 @@ Chain.prototype.add = function add(initial, peer, callback) {
|
||||
self.orphan.map[prevHash] = block;
|
||||
self.orphan.bmap[hash] = block;
|
||||
code = Chain.codes.newOrphan;
|
||||
total++;
|
||||
// total++;
|
||||
return done(null, code);
|
||||
}
|
||||
|
||||
@ -1004,6 +1008,7 @@ Chain.prototype.add = function add(initial, peer, callback) {
|
||||
}
|
||||
|
||||
if (code !== Chain.codes.okay) {
|
||||
if (0)
|
||||
if (!(self.options.multiplePeers && code === Chain.codes.newOrphan))
|
||||
utils.debug('Chain Error: %s', Chain.msg(code));
|
||||
}
|
||||
|
||||
@ -662,7 +662,8 @@ Pool.prototype._handleBlock = function _handleBlock(block, peer, callback) {
|
||||
|
||||
// Ignore if we already have.
|
||||
if (self.chain.has(block)) {
|
||||
utils.debug('Already have block %s (%s)', block.height, peer.host);
|
||||
utils.debug('Already have block %s (%s)',
|
||||
self.chain.getHeight(block), peer.host);
|
||||
self.setMisbehavior(peer, 1);
|
||||
return done(null, false);
|
||||
}
|
||||
@ -769,14 +770,14 @@ Pool.prototype._addIndex = function _addIndex(block, peer, callback) {
|
||||
// self._nextBlock(peer);
|
||||
// }
|
||||
|
||||
if (peer._requesting)
|
||||
if (added > 0 && peer._requesting)
|
||||
delete peer._requesting;
|
||||
|
||||
self._nextBlock(peer);
|
||||
|
||||
self.block.total += added;
|
||||
|
||||
if (self.chain.height() % 100 === 0) {
|
||||
if (self.chain.height() % 20 === 0) {
|
||||
utils.debug(
|
||||
'Got: %s from %s chain len %d blocks %d orp %d act %d queue %d target %s peers %d',
|
||||
block.rhash,
|
||||
@ -1614,19 +1615,21 @@ Pool.prototype._nextBlock = function _nextBlock(peer) {
|
||||
if (peer._requesting)
|
||||
return;
|
||||
|
||||
item = peer._blockQueue.shift();
|
||||
// item = peer._blockQueue.shift();
|
||||
item = peer._blockQueue.slice(0, 5);
|
||||
peer._blockQueue = peer._blockQueue.slice(5);
|
||||
|
||||
if (peer.destroyed)
|
||||
return;
|
||||
|
||||
if (!item)
|
||||
if (!item.length)
|
||||
return;
|
||||
|
||||
// XXX MAYBE ONLY CREATE LOAD REQUEST HERE
|
||||
|
||||
utils.debug(
|
||||
'Requesting block %s (%d/%d) from %s with getdata (height %d)',
|
||||
utils.revHex(item.hash),
|
||||
utils.revHex(item[0].hash),
|
||||
peer._blockQueue.length,
|
||||
this.request.active,
|
||||
peer.host,
|
||||
@ -1634,7 +1637,7 @@ Pool.prototype._nextBlock = function _nextBlock(peer) {
|
||||
|
||||
peer._requesting = item;
|
||||
|
||||
peer.getData([item]);
|
||||
peer.getData(item);
|
||||
};
|
||||
|
||||
Pool.prototype._response = function _response(hash) {
|
||||
@ -1953,6 +1956,7 @@ Pool.prototype.removeSeed = function removeSeed(seed) {
|
||||
};
|
||||
|
||||
Pool.prototype.isOrphaning = function isOrphaning(peer) {
|
||||
return false;
|
||||
if (utils.now() > peer.orphanTime + 3 * 60) {
|
||||
peer.orphans = 0;
|
||||
peer.orphanTime = utils.now();
|
||||
|
||||
@ -2048,8 +2048,10 @@ script.isValidKey = function isValidKey(key, flags) {
|
||||
return false;
|
||||
|
||||
if (flags & constants.flags.VERIFY_STRICTENC) {
|
||||
if (!script.isKeyEncoding(key))
|
||||
if (!script.isKeyEncoding(key)) {
|
||||
utils.debug('Script failed key encoding test.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -2089,18 +2091,24 @@ script.isValidSignature = function isValidSignature(sig, flags) {
|
||||
if ((flags & constants.flags.VERIFY_DERSIG)
|
||||
|| (flags & constants.flags.VERIFY_LOW_S)
|
||||
|| (flags & constants.flags.VERIFY_STRICTENC)) {
|
||||
if (!script.isSignatureEncoding(sig))
|
||||
if (!script.isSignatureEncoding(sig)) {
|
||||
utils.debug('Script does not have a proper signature encoding.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & constants.flags.VERIFY_LOW_S) {
|
||||
if (!script.isLowDER(sig))
|
||||
if (!script.isLowDER(sig)) {
|
||||
utils.debug('Script does not have a low DER.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & constants.flags.VERIFY_STRICTENC) {
|
||||
if (!script.isHashType(sig))
|
||||
if (!script.isHashType(sig)) {
|
||||
utils.debug('Script does not have a valid hash type.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -918,8 +918,10 @@ TX.prototype.verify = function verify(index, force, flags) {
|
||||
if (index != null && i !== index)
|
||||
return true;
|
||||
|
||||
if (!input.output)
|
||||
if (!input.output) {
|
||||
utils.debug('Warning: Not all outputs available for tx.verify().');
|
||||
return false;
|
||||
}
|
||||
|
||||
return bcoin.script.verify(input.script, input.output.script, this, i, flags);
|
||||
}, this);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user