-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: libwaku retrieve my enr and adapt golang example #2987
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package main | ||
|
||
/* | ||
#cgo LDFLAGS: -L../../build/ -lwaku -Wl,--allow-multiple-definition | ||
#cgo LDFLAGS: -L../../build/ -lwaku -lnegentropy -Wl,--allow-multiple-definition | ||
#cgo LDFLAGS: -L../../ -Wl,-rpath,../../ | ||
|
||
#include "../../library/libwaku.h" | ||
#include <stdio.h> | ||
|
@@ -171,6 +172,10 @@ package main | |
WAKU_CALL (waku_listen_addresses(ctx, (WakuCallBack) callback, resp) ); | ||
} | ||
|
||
void cGoWakuGetMyENR(void* ctx, void* resp) { | ||
WAKU_CALL (waku_get_my_enr(ctx, (WakuCallBack) callback, resp) ); | ||
} | ||
|
||
*/ | ||
import "C" | ||
|
||
|
@@ -446,6 +451,20 @@ func (self *WakuNode) WakuListenAddresses() (string, error) { | |
return "", errors.New(errMsg) | ||
} | ||
|
||
func (self *WakuNode) WakuGetMyENR() (string, error) { | ||
var resp = C.allocResp() | ||
defer C.freeResp(resp) | ||
C.cGoWakuGetMyENR(self.ctx, resp) | ||
|
||
if C.getRet(resp) == C.RET_OK { | ||
var listenAddresses = C.GoStringN(C.getMyCharPtr(resp), C.int(C.getMyCharLen(resp))) | ||
return listenAddresses, nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we change the variable name to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ooh @NagyZoltanPeter added the same comment a few minutes before I did lol. Nice! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you so much guys ! I'll change that |
||
} | ||
errMsg := "error WakuGetMyENR: " + | ||
C.GoStringN(C.getMyCharPtr(resp), C.int(C.getMyCharLen(resp))) | ||
return "", errors.New(errMsg) | ||
} | ||
|
||
func main() { | ||
WakuSetup() | ||
|
||
|
@@ -516,11 +535,18 @@ func main() { | |
return | ||
} | ||
|
||
myENR, err := node.WakuGetMyENR() | ||
if err != nil { | ||
fmt.Println("Error happened:", err.Error()) | ||
return | ||
} | ||
|
||
fmt.Println("Version:", version) | ||
fmt.Println("Custom content topic:", formattedContentTopic) | ||
fmt.Println("Custom pubsub topic:", formattedPubsubTopic) | ||
fmt.Println("Default pubsub topic:", defaultPubsubTopic) | ||
fmt.Println("Listen addresses:", listenAddresses) | ||
fmt.Println("My ENR:", myENR) | ||
|
||
// Wait for a SIGINT or SIGTERM signal | ||
ch := make(chan os.Signal, 1) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a bit misleading to call it listenAddresses and not the ENR.
I remember that is different also in /debug/info API result.