les: fix server panic when discovery disabled

This commit is contained in:
Zsolt Felfoldi 2018-02-09 20:23:07 +01:00
parent 42628ba7ed
commit b4e7efdd42

View file

@ -111,6 +111,7 @@ 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)
if srvr.DiscV5 != nil {
for _, topic := range s.lesTopics { for _, topic := range s.lesTopics {
topic := topic topic := topic
go func() { go func() {
@ -121,6 +122,7 @@ func (s *LesServer) Start(srvr *p2p.Server) {
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()
} }