check to see if chain is synced.
This commit is contained in:
parent
34e90c6baa
commit
cf502913b6
@ -60,6 +60,8 @@ function Pool(options) {
|
|||||||
(Math.random() * 0xffffffff) | 0);
|
(Math.random() * 0xffffffff) | 0);
|
||||||
|
|
||||||
this.bestHeight = 0;
|
this.bestHeight = 0;
|
||||||
|
this.bestBlock = null;
|
||||||
|
this.needSync = true;
|
||||||
|
|
||||||
this.peers = {
|
this.peers = {
|
||||||
// Peers that are loading blocks themselves
|
// Peers that are loading blocks themselves
|
||||||
@ -367,6 +369,12 @@ Pool.prototype._addPeer = function _addPeer(backoff) {
|
|||||||
if (self.chain.index.hashes.length === len)
|
if (self.chain.index.hashes.length === len)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var top = self.chain.index.hashes[self.chain.index.hashes.length - 1];
|
||||||
|
if (top === self.bestBlock)
|
||||||
|
self.needSync = false;
|
||||||
|
else
|
||||||
|
self.needSync = true;
|
||||||
|
|
||||||
self.emit('chain-progress', self.chain.fillPercent(), peer);
|
self.emit('chain-progress', self.chain.fillPercent(), peer);
|
||||||
self.emit('block', block, peer);
|
self.emit('block', block, peer);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user