diff options
author | Felföldi Zsolt <zsfelfoldi@gmail.com> | 2018-02-10 20:33:52 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-02-10 20:33:52 +0800 |
commit | 2f849ade8204a4b417202d90c66e2f5bef4e965d (patch) | |
tree | ee766ce7fe06dfea3ecbf4997446bedd854b7fe2 /les | |
parent | a00f4a12a95d2bba00b46a58de8232167137fd1e (diff) | |
download | go-tangerine-2f849ade8204a4b417202d90c66e2f5bef4e965d.tar go-tangerine-2f849ade8204a4b417202d90c66e2f5bef4e965d.tar.gz go-tangerine-2f849ade8204a4b417202d90c66e2f5bef4e965d.tar.bz2 go-tangerine-2f849ade8204a4b417202d90c66e2f5bef4e965d.tar.lz go-tangerine-2f849ade8204a4b417202d90c66e2f5bef4e965d.tar.xz go-tangerine-2f849ade8204a4b417202d90c66e2f5bef4e965d.tar.zst go-tangerine-2f849ade8204a4b417202d90c66e2f5bef4e965d.zip |
les: fix server panic when discovery disabled (#16055)
Diffstat (limited to 'les')
-rw-r--r-- | les/server.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/les/server.go b/les/server.go index 85ebbf898..65b8c357d 100644 --- a/les/server.go +++ b/les/server.go @@ -111,15 +111,17 @@ func (s *LesServer) Protocols() []p2p.Protocol { // Start starts the LES server func (s *LesServer) Start(srvr *p2p.Server) { s.protocolManager.Start(s.config.LightPeers) - for _, topic := range s.lesTopics { - topic := topic - go func() { - logger := log.New("topic", topic) - logger.Info("Starting topic registration") - defer logger.Info("Terminated topic registration") - - srvr.DiscV5.RegisterTopic(topic, s.quitSync) - }() + if srvr.DiscV5 != nil { + for _, topic := range s.lesTopics { + topic := topic + go func() { + logger := log.New("topic", topic) + logger.Info("Starting topic registration") + defer logger.Info("Terminated topic registration") + + srvr.DiscV5.RegisterTopic(topic, s.quitSync) + }() + } } s.privateKey = srvr.PrivateKey s.protocolManager.blockLoop() |