diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index 1cc86279..b2b2d69f 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -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); });