-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce44751
commit 4e26797
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
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") | ||
|