les: fix server panic when discovery disabled (#16055)

pull/16059/head
Felföldi Zsolt 7 years ago committed by Péter Szilágyi
parent a00f4a12a9
commit 2f849ade82
  1. 20
      les/server.go

@ -111,15 +111,17 @@ func (s *LesServer) Protocols() []p2p.Protocol {
// Start starts the LES server // Start starts the LES server
func (s *LesServer) Start(srvr *p2p.Server) { func (s *LesServer) Start(srvr *p2p.Server) {
s.protocolManager.Start(s.config.LightPeers) s.protocolManager.Start(s.config.LightPeers)
for _, topic := range s.lesTopics { if srvr.DiscV5 != nil {
topic := topic for _, topic := range s.lesTopics {
go func() { topic := topic
logger := log.New("topic", topic) go func() {
logger.Info("Starting topic registration") logger := log.New("topic", topic)
defer logger.Info("Terminated topic registration") logger.Info("Starting topic registration")
defer logger.Info("Terminated topic registration")
srvr.DiscV5.RegisterTopic(topic, s.quitSync)
}() srvr.DiscV5.RegisterTopic(topic, s.quitSync)
}()
}
} }
s.privateKey = srvr.PrivateKey s.privateKey = srvr.PrivateKey
s.protocolManager.blockLoop() s.protocolManager.blockLoop()

Loading…
Cancel
Save