aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-05-28 06:28:39 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-05-28 06:28:39 +0800
commit27e0d2a97325edc9a870a747412d0b9a2abd1ed1 (patch)
tree8a5179b93fa118164164b66bff2a0f5d0ccc0450
parent5479be9f6412ccd60e86d6c9be972894cf99abdf (diff)
parent5235e01b8dac36a847723fc83cfd5ff65c903215 (diff)
downloadgo-tangerine-27e0d2a97325edc9a870a747412d0b9a2abd1ed1.tar.gz
go-tangerine-27e0d2a97325edc9a870a747412d0b9a2abd1ed1.tar.zst
go-tangerine-27e0d2a97325edc9a870a747412d0b9a2abd1ed1.zip
Merge pull request #1128 from karalabe/hard-disconnect-trial
eth: hard disconnect if a peer is flaky
-rw-r--r--eth/handler.go16
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() {