2023-08-10 13:30:38 +00:00
|
|
|
package gowaku
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/waku-org/go-waku/library"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DNSDiscovery executes dns discovery on an url and returns a list of nodes
|
|
|
|
func DNSDiscovery(url string, nameserver string, ms int) string {
|
|
|
|
response, err := library.DNSDiscovery(url, nameserver, ms)
|
|
|
|
return prepareJSONResponse(response, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// StartDiscoveryV5 starts discv5 discovery
|
2023-12-15 14:46:21 +00:00
|
|
|
func StartDiscoveryV5(instanceID uint) string {
|
|
|
|
instance, err := library.GetInstance(instanceID)
|
|
|
|
if err != nil {
|
|
|
|
return makeJSONResponse(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = library.StartDiscoveryV5(instance)
|
2023-08-10 13:30:38 +00:00
|
|
|
return makeJSONResponse(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// StopDiscoveryV5 stops discv5 discovery
|
2023-12-15 14:46:21 +00:00
|
|
|
func StopDiscoveryV5(instanceID uint) string {
|
|
|
|
instance, err := library.GetInstance(instanceID)
|
|
|
|
if err != nil {
|
|
|
|
return makeJSONResponse(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = library.StopDiscoveryV5(instance)
|
2023-08-10 13:30:38 +00:00
|
|
|
return makeJSONResponse(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetBootnodes is used to update the bootnodes receiving a JSON array of ENRs
|
2023-12-15 14:46:21 +00:00
|
|
|
func SetBootnodes(instanceID uint, bootnodes string) string {
|
|
|
|
instance, err := library.GetInstance(instanceID)
|
|
|
|
if err != nil {
|
|
|
|
return makeJSONResponse(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = library.SetBootnodes(instance, bootnodes)
|
2023-08-10 13:30:38 +00:00
|
|
|
return makeJSONResponse(err)
|
|
|
|
}
|