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);
|
||||
|
||||
this.bestHeight = 0;
|
||||
this.bestBlock = null;
|
||||
this.needSync = true;
|
||||
|
||||
this.peers = {
|
||||
// Peers that are loading blocks themselves
|
||||
@ -367,6 +369,12 @@ Pool.prototype._addPeer = function _addPeer(backoff) {
|
||||
if (self.chain.index.hashes.length === len)
|
||||
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('block', block, peer);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user