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

@ -38,6 +38,7 @@ import (
)
type LesServer struct {
config *eth.Config
protocolManager *ProtocolManager
fcManager *flowcontrol.ClientManager // nil if our node is client only
fcCostStats *requestCostStats
@ -62,6 +63,7 @@ func NewLesServer(eth *eth.Ethereum, config *eth.Config) (*LesServer, error) {
}
srv := &LesServer{
config: config,
protocolManager: pm,
quitSync: quitSync,
lesTopics: lesTopics,
@ -108,7 +110,7 @@ func (s *LesServer) Protocols() []p2p.Protocol {
// Start starts the LES server
func (s *LesServer) Start(srvr *p2p.Server) {
s.protocolManager.Start()
s.protocolManager.Start(s.config.LightPeers)
for _, topic := range s.lesTopics {
topic := topic
go func() {