2025-12-19 17:00:43 +01:00
|
|
|
import std/json
|
|
|
|
|
import
|
|
|
|
|
chronicles,
|
|
|
|
|
chronos,
|
|
|
|
|
results,
|
|
|
|
|
eth/p2p/discoveryv5/enr,
|
|
|
|
|
strutils,
|
|
|
|
|
libp2p/peerid,
|
|
|
|
|
metrics,
|
|
|
|
|
ffi
|
2026-01-29 15:48:34 +01:00
|
|
|
import
|
2026-06-25 09:27:01 +02:00
|
|
|
logos_delivery/waku/waku,
|
2026-06-08 13:37:53 +02:00
|
|
|
logos_delivery/waku/node/waku_node,
|
|
|
|
|
logos_delivery/waku/node/health_monitor,
|
|
|
|
|
library/declare_lib
|
2025-12-19 17:00:43 +01:00
|
|
|
|
|
|
|
|
proc getMultiaddresses(node: WakuNode): seq[string] =
|
|
|
|
|
return node.info().listenAddresses
|
|
|
|
|
|
|
|
|
|
proc getMetrics(): string =
|
|
|
|
|
{.gcsafe.}:
|
|
|
|
|
return defaultRegistry.toText() ## defaultRegistry is {.global.} in metrics module
|
|
|
|
|
|
|
|
|
|
proc waku_version(
|
2026-06-23 01:20:09 +02:00
|
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
2025-12-19 17:00:43 +01:00
|
|
|
) {.ffi.} =
|
|
|
|
|
return ok(WakuNodeVersionString)
|
|
|
|
|
|
|
|
|
|
proc waku_listen_addresses(
|
2026-06-23 01:20:09 +02:00
|
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
2025-12-19 17:00:43 +01:00
|
|
|
) {.ffi.} =
|
|
|
|
|
## returns a comma-separated string of the listen addresses
|
2026-06-23 01:20:09 +02:00
|
|
|
return ok(ctx.myLib[].waku.node.getMultiaddresses().join(","))
|
2025-12-19 17:00:43 +01:00
|
|
|
|
|
|
|
|
proc waku_get_my_enr(
|
2026-06-23 01:20:09 +02:00
|
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
2025-12-19 17:00:43 +01:00
|
|
|
) {.ffi.} =
|
2026-06-23 01:20:09 +02:00
|
|
|
return ok(ctx.myLib[].waku.node.enr.toURI())
|
2025-12-19 17:00:43 +01:00
|
|
|
|
|
|
|
|
proc waku_get_my_peerid(
|
2026-06-23 01:20:09 +02:00
|
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
2025-12-19 17:00:43 +01:00
|
|
|
) {.ffi.} =
|
2026-06-23 01:20:09 +02:00
|
|
|
return ok($ctx.myLib[].waku.node.peerId())
|
2025-12-19 17:00:43 +01:00
|
|
|
|
|
|
|
|
proc waku_get_metrics(
|
2026-06-23 01:20:09 +02:00
|
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
2025-12-19 17:00:43 +01:00
|
|
|
) {.ffi.} =
|
|
|
|
|
return ok(getMetrics())
|
|
|
|
|
|
|
|
|
|
proc waku_is_online(
|
2026-06-23 01:20:09 +02:00
|
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
2025-12-19 17:00:43 +01:00
|
|
|
) {.ffi.} =
|
2026-06-23 01:20:09 +02:00
|
|
|
return ok($ctx.myLib[].waku.healthMonitor.onlineMonitor.amIOnline())
|