aboutsummaryrefslogtreecommitdiffstats
path: root/eth/handler.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-05-29 00:01:40 +0800
committerobscuren <geffobscura@gmail.com>2015-05-29 00:01:40 +0800
commitf082c1b8959c1c729a4b62d6ff101d7569e8ba0f (patch)
treed19fdc2e8982a64d93612677dc2722dd41c8dbd3 /eth/handler.go
parent70867904a0255bd044851585a9ad2dc34391ced2 (diff)
parentd51d74eb55535db7670ad336d186ea64c6a2ff81 (diff)
downloaddexon-f082c1b8959c1c729a4b62d6ff101d7569e8ba0f.tar
dexon-f082c1b8959c1c729a4b62d6ff101d7569e8ba0f.tar.gz
dexon-f082c1b8959c1c729a4b62d6ff101d7569e8ba0f.tar.bz2
dexon-f082c1b8959c1c729a4b62d6ff101d7569e8ba0f.tar.lz
dexon-f082c1b8959c1c729a4b62d6ff101d7569e8ba0f.tar.xz
dexon-f082c1b8959c1c729a4b62d6ff101d7569e8ba0f.tar.zst
dexon-f082c1b8959c1c729a4b62d6ff101d7569e8ba0f.zip
Merge branch 'release/0.9.26'
Diffstat (limited to 'eth/handler.go')
-rw-r--r--eth/handler.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/eth/handler.go b/eth/handler.go
index 777a9c7c0..aea33452c 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -2,7 +2,6 @@ package eth
import (
"fmt"
- "math"
"math/big"
"sync"
"time"
@@ -93,14 +92,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() {
@@ -351,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)
}