diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-05-27 23:58:51 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-05-27 23:58:51 +0800 |
commit | 5235e01b8dac36a847723fc83cfd5ff65c903215 (patch) | |
tree | 917e3d71e9c30eef0b126ca8aeb9cb7106e0ae5c /eth/handler.go | |
parent | 8951a03db39a2a877ada34c927d78352d465303e (diff) | |
download | go-tangerine-5235e01b8dac36a847723fc83cfd5ff65c903215.tar go-tangerine-5235e01b8dac36a847723fc83cfd5ff65c903215.tar.gz go-tangerine-5235e01b8dac36a847723fc83cfd5ff65c903215.tar.bz2 go-tangerine-5235e01b8dac36a847723fc83cfd5ff65c903215.tar.lz go-tangerine-5235e01b8dac36a847723fc83cfd5ff65c903215.tar.xz go-tangerine-5235e01b8dac36a847723fc83cfd5ff65c903215.tar.zst go-tangerine-5235e01b8dac36a847723fc83cfd5ff65c903215.zip |
eth: hard disconnect if a peer is flaky
Diffstat (limited to 'eth/handler.go')
-rw-r--r-- | eth/handler.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/eth/handler.go b/eth/handler.go index 777a9c7c0..8092a5f71 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -93,14 +93,22 @@ func NewProtocolManager(protocolVersion, networkId int, mux *event.TypeMux, txpo } func (pm *ProtocolManager) removePeer(id string) { - // Unregister the peer from the downloader - pm.downloader.UnregisterPeer(id) + // Short circuit if the peer was already removed + 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 - glog.V(logger.Detail).Infoln("Removing peer", id) + // Unregister the peer from the downloader and Ethereum peer set + pm.downloader.UnregisterPeer(id) if err := pm.peers.Unregister(id); err != nil { 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() { |