mirror of https://github.com/status-im/go-waku.git
fix(c-bindings): simplify discv5 API
This commit is contained in:
parent
26daf72a23
commit
2c9c763c30
|
@ -17,17 +17,3 @@ func waku_dns_discovery(url *C.char, nameserver *C.char, ms C.int) *C.char {
|
|||
response := mobile.DnsDiscovery(C.GoString(url), C.GoString(nameserver), int(ms))
|
||||
return C.CString(response)
|
||||
}
|
||||
|
||||
// Starts DiscoveryV5 service to discover and connect to new peers
|
||||
//export waku_discv5_start
|
||||
func waku_discv5_start() *C.char {
|
||||
response := mobile.StartDiscoveryV5()
|
||||
return C.CString(response)
|
||||
}
|
||||
|
||||
// Stops DiscoveryV5 service
|
||||
//export waku_discv5_stop
|
||||
func waku_discv5_stop() *C.char {
|
||||
response := mobile.StopDiscoveryV5()
|
||||
return C.CString(response)
|
||||
}
|
||||
|
|
|
@ -207,6 +207,13 @@ func Start() string {
|
|||
return MakeJSONResponse(err)
|
||||
}
|
||||
|
||||
if wakuNode.DiscV5() != nil {
|
||||
if err := wakuNode.DiscV5().Start(context.Background()); err != nil {
|
||||
wakuNode.Stop()
|
||||
return MakeJSONResponse(err)
|
||||
}
|
||||
}
|
||||
|
||||
wakuStarted = true
|
||||
|
||||
return MakeJSONResponse(nil)
|
||||
|
|
|
@ -209,11 +209,13 @@ func (d *DiscoveryV5) Stop() {
|
|||
|
||||
d.cancel()
|
||||
|
||||
d.listener.Close()
|
||||
d.listener = nil
|
||||
d.started = false
|
||||
|
||||
if d.listener != nil {
|
||||
d.listener.Close()
|
||||
d.listener = nil
|
||||
d.log.Info("stopped Discovery V5")
|
||||
}
|
||||
|
||||
d.wg.Wait()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue