go-waku/library/c/api_discovery.go

38 lines
1.2 KiB
Go
Raw Normal View History

package main
2023-08-10 13:30:38 +00:00
/*
#include <cgo_utils.h>
*/
import "C"
2023-10-28 23:37:53 +00:00
import (
"unsafe"
"github.com/waku-org/go-waku/library"
)
// Returns a list of objects containing the peerID, enr and multiaddresses for each node found
2023-06-09 12:43:41 +00:00
//
// given a url to a DNS discoverable ENR tree
//
// The nameserver can optionally be specified to resolve the enrtree url. Otherwise NULL or
// empty to automatically use the default system dns.
// If ms is greater than 0, the subscription must happen before the timeout
// (in milliseconds) is reached, or an error will be returned
//
//export waku_dns_discovery
2023-10-28 23:37:53 +00:00
func waku_dns_discovery(url *C.char, nameserver *C.char, ms C.int, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
2023-08-10 13:30:38 +00:00
return singleFnExec(func() (string, error) {
return library.DNSDiscovery(C.GoString(url), C.GoString(nameserver), int(ms))
2023-10-28 23:37:53 +00:00
}, cb, userData)
}
2023-06-09 12:43:41 +00:00
// Update the bootnode list used for discovering new peers via DiscoveryV5
// The bootnodes param should contain a JSON array containing the bootnode ENRs i.e. `["enr:...", "enr:..."]`
//
//export waku_discv5_update_bootnodes
2023-10-28 23:37:53 +00:00
func waku_discv5_update_bootnodes(bootnodes *C.char, cb C.WakuCallBack, userData unsafe.Pointer) C.int {
2023-08-10 13:30:38 +00:00
err := library.SetBootnodes(C.GoString(bootnodes))
2023-10-28 23:37:53 +00:00
return onError(err, cb, userData)
2023-06-09 12:43:41 +00:00
}