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.bestHeight = 0;
|
||||||
|
|
||||||
this.peers = {
|
this.peers = {
|
||||||
|
// Peers that have a forked blockchain
|
||||||
|
// bad: [],
|
||||||
// Peers that are loading blocks themselves
|
// Peers that are loading blocks themselves
|
||||||
block: [],
|
block: [],
|
||||||
// Peers that are still connecting
|
// 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
|
// Just FYI
|
||||||
peer.on('reject', function(payload) {
|
peer.on('reject', function(payload) {
|
||||||
self.emit('reject', payload, peer);
|
self.emit('reject', payload, peer);
|
||||||
@ -425,6 +434,8 @@ Pool.prototype.bestPeer = function bestPeer() {
|
|||||||
this.peers.block.forEach(function(peer) {
|
this.peers.block.forEach(function(peer) {
|
||||||
if (!peer.version || !peer.socket)
|
if (!peer.version || !peer.socket)
|
||||||
return;
|
return;
|
||||||
|
// if (~self.peers.bad.indexOf(peer))
|
||||||
|
// return;
|
||||||
if (!best || peer.version.height > best.version.height)
|
if (!best || peer.version.height > best.version.height)
|
||||||
best = peer;
|
best = peer;
|
||||||
});
|
});
|
||||||
@ -443,6 +454,8 @@ Pool.prototype.startSync = function startSync(peer) {
|
|||||||
if (!peer)
|
if (!peer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
this.syncPeer = peer;
|
||||||
|
|
||||||
peer.startSync();
|
peer.startSync();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user