From f085237df30f7f6e955c7c395d44ff75fd4add2d Mon Sep 17 00:00:00 2001 From: zsfelfoldi Date: Sun, 26 Jun 2016 02:10:49 +0200 Subject: [PATCH] eth: hack to limit number of eth peers --- eth/handler.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eth/handler.go b/eth/handler.go index 8d5088a0cc..e8282597b3 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -249,6 +249,10 @@ func (pm *ProtocolManager) newPeer(pv int, p *p2p.Peer, rw p2p.MsgReadWriter) *p // handle is the callback invoked to manage the life cycle of an eth peer. When // this function terminates, the peer is disconnected. func (pm *ProtocolManager) handle(p *peer) error { + if pm.peers.Len() >= 20 { + return p2p.DiscTooManyPeers + } + glog.V(logger.Debug).Infof("%v: peer connected [%s]", p, p.Name()) // Execute the Ethereum handshake