mirror of
https://github.com/status-im/status-go.git
synced 2025-02-20 10:48:36 +00:00
integrating waku_get_my_peerid
This commit is contained in:
parent
c744d59fee
commit
ad92af7add
@ -208,6 +208,10 @@ package wakuv2
|
||||
WAKU_CALL (waku_get_my_enr(ctx, (WakuCallBack) callback, resp) );
|
||||
}
|
||||
|
||||
static void cGoWakuGetMyPeerId(void* ctx, void* resp) {
|
||||
WAKU_CALL (waku_get_my_peerid(ctx, (WakuCallBack) callback, resp) );
|
||||
}
|
||||
|
||||
static void cGoWakuListPeersInMesh(void* ctx, char* pubSubTopic, void* resp) {
|
||||
WAKU_CALL (waku_relay_get_num_peers_in_mesh(ctx, pubSubTopic, (WakuCallBack) callback, resp) );
|
||||
}
|
||||
@ -1599,9 +1603,24 @@ func (w *Waku) Clean() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *Waku) PeerID() peer.ID {
|
||||
// return w.node.Host().ID()
|
||||
return ""
|
||||
func (w *Waku) PeerID() (peer.ID, error) {
|
||||
var resp = C.allocResp()
|
||||
defer C.freeResp(resp)
|
||||
C.cGoWakuGetMyPeerId(w.wakuCtx, resp)
|
||||
|
||||
if C.getRet(resp) == C.RET_OK {
|
||||
|
||||
peerIdStr := C.GoStringN(C.getMyCharPtr(resp), C.int(C.getMyCharLen(resp)))
|
||||
id, err := peermod.Decode(peerIdStr)
|
||||
if err != nil {
|
||||
errMsg := "WakuGetMyPeerId - error decoding peerId: " + err.Error()
|
||||
return "", errors.New(errMsg)
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
errMsg := "error WakuGetMyPeerId: " +
|
||||
C.GoStringN(C.getMyCharPtr(resp), C.int(C.getMyCharLen(resp)))
|
||||
return "", errors.New(errMsg)
|
||||
}
|
||||
|
||||
func (w *Waku) Peerstore() peerstore.Peerstore {
|
||||
|
Loading…
x
Reference in New Issue
Block a user