-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: bindings return multiaddress array (#2461)
* waku_example.c: adapt signature to new parameter 'void* userData' * libwaku: add new DEBUG request handler to retrieve the list of listened multiaddresses * waku_example.c: use example the new 'waku_listen_addresses' * add debug_node_request.nim file
- Loading branch information
1 parent
d01585e
commit 7aea145
Showing
5 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
library/waku_thread/inter_thread_communication/requests/debug_node_request.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
import | ||
std/[options,sequtils,strutils,json] | ||
import | ||
chronicles, | ||
chronos, | ||
stew/results, | ||
stew/shims/net | ||
import | ||
../../../../waku/node/waku_node, | ||
../../../alloc | ||
|
||
type | ||
DebugNodeMsgType* = enum | ||
RETRIEVE_LISTENING_ADDRESSES | ||
|
||
type | ||
DebugNodeRequest* = object | ||
operation: DebugNodeMsgType | ||
|
||
proc createShared*(T: type DebugNodeRequest, | ||
op: DebugNodeMsgType): ptr type T = | ||
|
||
var ret = createShared(T) | ||
ret[].operation = op | ||
return ret | ||
|
||
proc destroyShared(self: ptr DebugNodeRequest) = | ||
deallocShared(self) | ||
|
||
proc getMultiaddresses(node: WakuNode): seq[string] = | ||
return node.info().listenAddresses | ||
|
||
proc process*(self: ptr DebugNodeRequest, | ||
node: WakuNode): Future[Result[string, string]] {.async.} = | ||
|
||
defer: destroyShared(self) | ||
|
||
case self.operation: | ||
of RETRIEVE_LISTENING_ADDRESSES: | ||
return ok($( %* node.getMultiaddresses())) | ||
|
||
return err("unsupported operation in DebugNodeRequest") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters