only update network height on orphan.
This commit is contained in:
parent
5dc4edbda5
commit
1b3d2ddaaa
@ -1437,15 +1437,6 @@ Chain.prototype.add = function add(block, callback, force) {
|
|||||||
|
|
||||||
height = !prev ? -1 : prev.height + 1;
|
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) {
|
if (height > self.bestHeight) {
|
||||||
self.bestHeight = height;
|
self.bestHeight = height;
|
||||||
network.height = height;
|
network.height = height;
|
||||||
@ -1458,11 +1449,22 @@ Chain.prototype.add = function add(block, callback, force) {
|
|||||||
self.orphan.size += block.getSize();
|
self.orphan.size += block.getSize();
|
||||||
self.orphan.map[prevHash] = block;
|
self.orphan.map[prevHash] = block;
|
||||||
self.orphan.bmap[hash] = 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, {
|
self.emit('orphan', block, {
|
||||||
height: block.getCoinbaseHeight(),
|
height: block.getCoinbaseHeight(),
|
||||||
hash: hash,
|
hash: hash,
|
||||||
seen: false
|
seen: false
|
||||||
});
|
});
|
||||||
|
|
||||||
return done(new VerifyError(block, 'invalid', 'bad-prevblk', 0));
|
return done(new VerifyError(block, 'invalid', 'bad-prevblk', 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user