mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-06-26 11:29:28 +00:00
* Move waku.nim from waku/factory to under waku/ * remove unused * Realize Kernel API in scope of Waku class * Refactor waku/api into messaging_client, waku/api/types and api_conf into logos_delivery/api * Make liblogosdelivery and wakunode2 compile, remove waku/api.nim as it was just a import orchestrator * make test compile and run * Reconcile master's new send tests to LogosDelivery API after rebase master commits #3965/#3669-followup added two test cases (Edge lightpush delivery #3847, store-validation timeout) written against the removed waku/api.nim createNode helper. Rewrite them to the LogosDelivery shape: createNode -> LogosDelivery.new, node.node -> node.waku.node, node.brokerCtx -> node.waku.brokerCtx, node.send -> node.messagingClient.send, and drop the now-implicit mountMessagingClient calls (LogosDelivery.new mounts the client internally).
54 lines
1.5 KiB
Nim
54 lines
1.5 KiB
Nim
import std/json
|
|
import
|
|
chronicles,
|
|
chronos,
|
|
results,
|
|
eth/p2p/discoveryv5/enr,
|
|
strutils,
|
|
libp2p/peerid,
|
|
metrics,
|
|
ffi
|
|
import
|
|
logos_delivery/waku/waku,
|
|
logos_delivery/waku/node/waku_node,
|
|
logos_delivery/waku/node/health_monitor,
|
|
library/declare_lib
|
|
|
|
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(
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
|
) {.ffi.} =
|
|
return ok(WakuNodeVersionString)
|
|
|
|
proc waku_listen_addresses(
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
|
) {.ffi.} =
|
|
## returns a comma-separated string of the listen addresses
|
|
return ok(ctx.myLib[].waku.node.getMultiaddresses().join(","))
|
|
|
|
proc waku_get_my_enr(
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
|
) {.ffi.} =
|
|
return ok(ctx.myLib[].waku.node.enr.toURI())
|
|
|
|
proc waku_get_my_peerid(
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
|
) {.ffi.} =
|
|
return ok($ctx.myLib[].waku.node.peerId())
|
|
|
|
proc waku_get_metrics(
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
|
) {.ffi.} =
|
|
return ok(getMetrics())
|
|
|
|
proc waku_is_online(
|
|
ctx: ptr FFIContext[LogosDelivery], callback: FFICallBack, userData: pointer
|
|
) {.ffi.} =
|
|
return ok($ctx.myLib[].waku.healthMonitor.onlineMonitor.amIOnline())
|