check to see if chain is synced.

This commit is contained in:
Christopher Jeffrey 2015-12-18 16:35:00 -08:00
parent 34e90c6baa
commit cf502913b6

View File

@ -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);
});