From 5235e01b8dac36a847723fc83cfd5ff65c903215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 27 May 2015 18:58:51 +0300 Subject: eth: hard disconnect if a peer is flaky --- eth/handler.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'eth/handler.go') 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() { -- cgit v1.2.3 From e5d7627427262f7df0906233aecbcbb37c8daeed Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 28 May 2015 17:01:44 +0200 Subject: eth: 100% block propogation --- eth/handler.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'eth/handler.go') diff --git a/eth/handler.go b/eth/handler.go index 8092a5f71..aea33452c 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -2,7 +2,6 @@ package eth import ( "fmt" - "math" "math/big" "sync" "time" @@ -359,7 +358,7 @@ func (pm *ProtocolManager) verifyTd(peer *peer, request newBlockMsgData) error { func (pm *ProtocolManager) BroadcastBlock(hash common.Hash, block *types.Block) { // Broadcast block to a batch of peers not knowing about it peers := pm.peers.PeersWithoutBlock(hash) - peers = peers[:int(math.Sqrt(float64(len(peers))))] + //peers = peers[:int(math.Sqrt(float64(len(peers))))] for _, peer := range peers { peer.sendNewBlock(block) } -- cgit v1.2.3