Merge pull request #1128 from karalabe/hard-disconnect-trial
eth: hard disconnect if a peer is flaky
This commit is contained in:
commit
27e0d2a973
@ -93,14 +93,22 @@ func NewProtocolManager(protocolVersion, networkId int, mux *event.TypeMux, txpo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pm *ProtocolManager) removePeer(id string) {
|
func (pm *ProtocolManager) removePeer(id string) {
|
||||||
// Unregister the peer from the downloader
|
// Short circuit if the peer was already removed
|
||||||
pm.downloader.UnregisterPeer(id)
|
peer := pm.peers.Peer(id)
|
||||||
|
if peer == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
glog.V(logger.Debug).Infoln("Removing peer", id)
|
||||||
|
|
||||||
// Remove the peer from the Ethereum peer set too
|
// Unregister the peer from the downloader and Ethereum peer set
|
||||||
glog.V(logger.Detail).Infoln("Removing peer", id)
|
pm.downloader.UnregisterPeer(id)
|
||||||
if err := pm.peers.Unregister(id); err != nil {
|
if err := pm.peers.Unregister(id); err != nil {
|
||||||
glog.V(logger.Error).Infoln("Removal failed:", err)
|
glog.V(logger.Error).Infoln("Removal failed:", err)
|
||||||
}
|
}
|
||||||
|
// Hard disconnect at the networking layer
|
||||||
|
if peer != nil {
|
||||||
|
peer.Peer.Disconnect(p2p.DiscUselessPeer)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pm *ProtocolManager) Start() {
|
func (pm *ProtocolManager) Start() {
|
||||||
|
Loading…
Reference in New Issue
Block a user