Skip to content

Commit

Permalink
add debug_node_request.nim file
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansete-status committed Feb 20, 2024
1 parent ce44751 commit 4e26797
Showing 1 changed file with 44 additions and 0 deletions.
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")

0 comments on commit 4e26797

Please sign in to comment.