aboutsummaryrefslogtreecommitdiffstats
path: root/eth/backend.go
diff options
context:
space:
mode:
authorFelföldi Zsolt <zsfelfoldi@gmail.com>2018-02-05 21:41:53 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-02-05 21:41:53 +0800
commitc3f238dd5371961d309350fb0f9d5136c9fc6afa (patch)
tree8879532944de4818030c0e8630613e52885695b6 /eth/backend.go
parentbc0666fb277be5e7d1fd7c5523a3b335b310a154 (diff)
downloadgo-tangerine-c3f238dd5371961d309350fb0f9d5136c9fc6afa.tar
go-tangerine-c3f238dd5371961d309350fb0f9d5136c9fc6afa.tar.gz
go-tangerine-c3f238dd5371961d309350fb0f9d5136c9fc6afa.tar.bz2
go-tangerine-c3f238dd5371961d309350fb0f9d5136c9fc6afa.tar.lz
go-tangerine-c3f238dd5371961d309350fb0f9d5136c9fc6afa.tar.xz
go-tangerine-c3f238dd5371961d309350fb0f9d5136c9fc6afa.tar.zst
go-tangerine-c3f238dd5371961d309350fb0f9d5136c9fc6afa.zip
les: limit LES peer count and improve peer configuration logic (#16010)
* les: limit number of LES connections * eth, cmd/utils: light vs max peer configuration logic
Diffstat (limited to 'eth/backend.go')
-rw-r--r--eth/backend.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/eth/backend.go b/eth/backend.go
index c39974a2c..bcd724c0c 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -393,10 +393,10 @@ func (s *Ethereum) Start(srvr *p2p.Server) error {
// Figure out a max peers count based on the server limits
maxPeers := srvr.MaxPeers
if s.config.LightServ > 0 {
- maxPeers -= s.config.LightPeers
- if maxPeers < srvr.MaxPeers/2 {
- maxPeers = srvr.MaxPeers / 2
+ if s.config.LightPeers >= srvr.MaxPeers {
+ return fmt.Errorf("invalid peer config: light peer count (%d) >= total peer count (%d)", s.config.LightPeers, srvr.MaxPeers)
}
+ maxPeers -= s.config.LightPeers
}
// Start the networking layer and the light server if requested
s.protocolManager.Start(maxPeers)