only update network height on orphan.

This commit is contained in:
Christopher Jeffrey 2016-05-04 04:25:14 -07:00
parent 5dc4edbda5
commit 1b3d2ddaaa
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1437,15 +1437,6 @@ Chain.prototype.add = function add(block, callback, force) {
height = !prev ? -1 : prev.height + 1;
// Update the best height based on the coinbase.
// We do this even for orphans (peers will send
// us their highest block during the initial
// getblocks sync, making it an orphan).
if (block.getCoinbaseHeight() > self.bestHeight) {
self.bestHeight = block.getCoinbaseHeight();
network.height = self.bestHeight;
}
if (height > self.bestHeight) {
self.bestHeight = height;
network.height = height;
@ -1458,11 +1449,22 @@ Chain.prototype.add = function add(block, callback, force) {
self.orphan.size += block.getSize();
self.orphan.map[prevHash] = block;
self.orphan.bmap[hash] = block;
// Update the best height based on the coinbase.
// We do this even for orphans (peers will send
// us their highest block during the initial
// getblocks sync, making it an orphan).
if (block.getCoinbaseHeight() > self.bestHeight) {
self.bestHeight = block.getCoinbaseHeight();
network.height = self.bestHeight;
}
self.emit('orphan', block, {
height: block.getCoinbaseHeight(),
hash: hash,
seen: false
});
return done(new VerifyError(block, 'invalid', 'bad-prevblk', 0));
}