From 5949360a820655744391aa3e0feb5660dda2a02d Mon Sep 17 00:00:00 2001 From: Ivan FB Date: Thu, 25 Jun 2026 00:40:02 +0200 Subject: [PATCH] Reshape per-layer API into api/ folders and thin the FFI over them Each layer now separates its constructible core from its public surface: - core module (waku.nim / messaging_client.nim / reliable_channel_manager.nim): the type plus new/start/stop and the private construction helpers. - api/ folder: one module per differentiated set of operations (waku: topics/relay/filter/lightpush/store/peer_manager/discovery/ debug/health) plus an events surface. The waku api is reshaped to be the complete operation surface the C bindings need, so the library no longer reaches into node internals: relayPublish returns the message hash, relaySubscribe takes an optional handler, filter/lightpush auto-select the service peer, connectedPeersInfo returns structured data, pingPeer honours the timeout, plus relayNumPeersInMesh / relayNumConnectedPeers / isOnline. library/ is now a thin C-ABI shim: each {.ffi.} proc only marshals cstring/JSON/callbacks and delegates to ctx.myLib[].waku. (or messagingClient.). app_callbacks re-exports the modules defining its handler types, which the included FFI files previously relied on by leakage. Events move next to the surface that owns them, with each dependency kept pointing the right way: - waku/events/ relocated under waku/api/events/. - channel events live in channels/api/events.nim. - the four messaging-level message events move to messaging/api/events; MessageSeenEvent stays in waku because it is emitted by waku core, so moving it would make waku depend on the messaging layer. - delivery_events renamed to filter_subscribe_events to match the OnFilterSubscribe/Unsubscribe events it actually declares. Co-Authored-By: Claude Opus 4.8 --- logos_delivery/channels/reliable_channel_manager.nim | 2 +- logos_delivery/logos_delivery.nim | 3 --- logos_delivery/waku/api/events/message_events.nim | 10 ++++++++++ 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 logos_delivery/waku/api/events/message_events.nim diff --git a/logos_delivery/channels/reliable_channel_manager.nim b/logos_delivery/channels/reliable_channel_manager.nim index d3f671c2b..c012ff436 100644 --- a/logos_delivery/channels/reliable_channel_manager.nim +++ b/logos_delivery/channels/reliable_channel_manager.nim @@ -28,7 +28,7 @@ type ## channel API. Placeholder for now (segmentation / SDS / rate-limit defaults ## will move here in a follow-up PR); kept so each layer owns its own config. - ReliableChannelManager* = ref object of IReliableChannelManager + ReliableChannelManager* = ref object channels*: Table[ChannelId, ReliableChannel] ## read by `channels/api.nim` messagingClient: MessagingClient ## The channel layer chains onto messaging. sendHandler*: SendHandler diff --git a/logos_delivery/logos_delivery.nim b/logos_delivery/logos_delivery.nim index 435bb968d..14cd3e737 100644 --- a/logos_delivery/logos_delivery.nim +++ b/logos_delivery/logos_delivery.nim @@ -11,9 +11,6 @@ import results, chronos, chronicles -import logos_delivery/api/logos_delivery_api -export logos_delivery_api - # Each layer has a core module (type + new/start/stop) and an api/ folder whose # modules each implement a differentiated set of operations, plus an events # surface. The concentrator re-exports them so library consumers get the full diff --git a/logos_delivery/waku/api/events/message_events.nim b/logos_delivery/waku/api/events/message_events.nim new file mode 100644 index 000000000..638d4f38a --- /dev/null +++ b/logos_delivery/waku/api/events/message_events.nim @@ -0,0 +1,10 @@ +import brokers/event_broker +import logos_delivery/api/types +import logos_delivery/waku/[waku_core/message, waku_core/topics] +export event_broker, types + +EventBroker: + # Internal event emitted when a message arrives from the network via any protocol + type MessageSeenEvent* = object + topic*: PubsubTopic + message*: WakuMessage