mirror of https://github.com/waku-org/nwaku.git
chore: add to libwaku peer id retrieval proc (#3124)
This commit is contained in:
parent
c35dc54923
commit
c5a825e206
|
@ -172,6 +172,10 @@ int waku_get_my_enr(void* ctx,
|
|||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_get_my_peerid(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_peer_exchange_request(void* ctx,
|
||||
int numPeers,
|
||||
WakuCallBack callback,
|
||||
|
|
|
@ -626,6 +626,19 @@ proc waku_get_my_enr(
|
|||
)
|
||||
.handleRes(callback, userData)
|
||||
|
||||
proc waku_get_my_peerid(
|
||||
ctx: ptr WakuContext, callback: WakuCallBack, userData: pointer
|
||||
): cint {.dynlib, exportc.} =
|
||||
checkLibwakuParams(ctx, callback, userData)
|
||||
|
||||
waku_thread
|
||||
.sendRequestToWakuThread(
|
||||
ctx,
|
||||
RequestType.DEBUG,
|
||||
DebugNodeRequest.createShared(DebugNodeMsgType.RETRIEVE_MY_PEER_ID),
|
||||
)
|
||||
.handleRes(callback, userData)
|
||||
|
||||
proc waku_start_discv5(
|
||||
ctx: ptr WakuContext, callback: WakuCallBack, userData: pointer
|
||||
): cint {.dynlib, exportc.} =
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import std/json
|
||||
import chronicles, chronos, results, eth/p2p/discoveryv5/enr, strutils
|
||||
import chronicles, chronos, results, eth/p2p/discoveryv5/enr, strutils, libp2p/peerid
|
||||
import ../../../../waku/factory/waku, ../../../../waku/node/waku_node
|
||||
|
||||
type DebugNodeMsgType* = enum
|
||||
RETRIEVE_LISTENING_ADDRESSES
|
||||
RETRIEVE_MY_ENR
|
||||
RETRIEVE_MY_PEER_ID
|
||||
|
||||
type DebugNodeRequest* = object
|
||||
operation: DebugNodeMsgType
|
||||
|
@ -32,6 +33,8 @@ proc process*(
|
|||
return ok(waku.node.getMultiaddresses().join(","))
|
||||
of RETRIEVE_MY_ENR:
|
||||
return ok(waku.node.enr.toURI())
|
||||
of RETRIEVE_MY_PEER_ID:
|
||||
return ok($waku.node.peerId())
|
||||
|
||||
error "unsupported operation in DebugNodeRequest"
|
||||
return err("unsupported operation in DebugNodeRequest")
|
||||
|
|
Loading…
Reference in New Issue