feat(library): add storeQuery and isStarted functions (#272)

This commit is contained in:
Richard Ramos 2022-07-26 14:23:26 -04:00 committed by GitHub
parent 069d66ed6d
commit f5936783c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -48,6 +48,13 @@ func waku_stop() *C.char {
return C.CString(response)
}
//export waku_is_started
// Determine is a node is started or not
func waku_is_started() *C.char {
response := mobile.IsStarted()
return C.CString(response)
}
//export waku_peerid
// Obtain the peer ID of the waku node
func waku_peerid() *C.char {

View File

@ -14,7 +14,7 @@ import (
// "startTime": 1234, // optional, unix epoch time in nanoseconds
// "endTime": 1234, // optional, unix epoch time in nanoseconds
// "contentFilters": [ // optional
// "contentTopic1", "contentTopic2" ...
// "contentTopic1", ...
// ],
// "pagingOptions": {// optional pagination information
// "pageSize": 40, // number

View File

@ -25,6 +25,7 @@ import (
)
var wakuNode *node.WakuNode
var wakuStarted = false
var errWakuNodeNotReady = errors.New("go-waku not initialized")
@ -151,6 +152,8 @@ func Start() string {
return makeJSONResponse(err)
}
wakuStarted = true
return makeJSONResponse(nil)
}
@ -160,11 +163,17 @@ func Stop() string {
}
wakuNode.Stop()
wakuStarted = false
wakuNode = nil
return makeJSONResponse(nil)
}
func IsStarted() string {
return prepareJSONResponse(wakuStarted, nil)
}
func PeerID() string {
if wakuNode == nil {
return makeJSONResponse(errWakuNodeNotReady)