diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index ad041b58..d776783c 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -62,6 +62,8 @@ function Pool(options) { this.bestHeight = 0; this.peers = { + // Peers that have a forked blockchain + // bad: [], // Peers that are loading blocks themselves block: [], // Peers that are still connecting @@ -369,6 +371,13 @@ Pool.prototype._addPeer = function _addPeer(backoff) { }); } + // Bad peer. + // this.chain.on('fork', function(height, hash, checkpoint) { + // // self.chain.resetLastCheckpoint(height); + // self.peers.bad.push(self.syncPeer); + // self.startSync(); + // }); + // Just FYI peer.on('reject', function(payload) { self.emit('reject', payload, peer); @@ -425,6 +434,8 @@ Pool.prototype.bestPeer = function bestPeer() { this.peers.block.forEach(function(peer) { if (!peer.version || !peer.socket) return; + // if (~self.peers.bad.indexOf(peer)) + // return; if (!best || peer.version.height > best.version.height) best = peer; }); @@ -443,6 +454,8 @@ Pool.prototype.startSync = function startSync(peer) { if (!peer) return; + this.syncPeer = peer; + peer.startSync(); };