chore: add to libwaku peer id retrieval proc (#3124)

This commit is contained in:
gabrielmer 2024-10-17 19:13:00 +03:00 committed by GitHub
parent c35dc54923
commit c5a825e206
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 1 deletions

View File

@ -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,

View File

@ -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.} =

View File

@ -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")