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
This commit is contained in:
committed by
Péter Szilágyi
parent
bc0666fb27
commit
c3f238dd53
@ -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)
|
||||
|
Reference in New Issue
Block a user