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:
Felföldi Zsolt
2018-02-05 14:41:53 +01:00
committed by Péter Szilágyi
parent bc0666fb27
commit c3f238dd53
7 changed files with 43 additions and 11 deletions

View File

@ -46,6 +46,8 @@ import (
)
type LightEthereum struct {
config *eth.Config
odr *LesOdr
relay *LesTxRelay
chainConfig *params.ChainConfig
@ -92,6 +94,7 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
quitSync := make(chan struct{})
leth := &LightEthereum{
config: config,
chainConfig: chainConfig,
chainDb: chainDb,
eventMux: ctx.EventMux,
@ -224,7 +227,7 @@ func (s *LightEthereum) Start(srvr *p2p.Server) error {
// clients are searching for the first advertised protocol in the list
protocolVersion := AdvertiseProtocolVersions[0]
s.serverPool.start(srvr, lesTopic(s.blockchain.Genesis().Hash(), protocolVersion))
s.protocolManager.Start()
s.protocolManager.Start(s.config.LightPeers)
return nil
}