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