add a peers.bad list for peers with forked blockchains.
This commit is contained in:
parent
5791672c07
commit
91618258e7
@ -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();
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user