mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-07-27 02:23:10 +00:00
The messaging api layer reached around the Waku kernel into the libp2p node (`waku.node.subscriptionManager`, `waku.node.rng`, `waku.node.brokerCtx`). That breaks the declared layering: messaging depends on the Waku *kernel* abstraction, not the raw node. Add a content-topic subscription api on the Waku layer (`waku/api/subscriptions.nim`) and switch the messaging send/subscription paths onto it, plus the kernel's own `rng`/`brokerCtx` fields, so the layer no longer touches `node` internals. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
24 lines
1.1 KiB
Nim
24 lines
1.1 KiB
Nim
## Waku layer API — content-topic subscription operations.
|
|
##
|
|
## These wrap the node's `SubscriptionManager`, which resolves each content
|
|
## topic to its autosharding shard. They give the layers above (messaging) a
|
|
## kernel-level entry point so they never reach into `waku.node` internals.
|
|
{.push raises: [].}
|
|
|
|
import results
|
|
|
|
import logos_delivery/waku/waku
|
|
import logos_delivery/waku/[waku_core, node/waku_node, node/subscription_manager]
|
|
|
|
proc subscribe*(self: Waku, contentTopic: ContentTopic): Result[void, string] =
|
|
## Subscribes to `contentTopic`, resolving its shard via autosharding.
|
|
return self.node.subscriptionManager.subscribe(contentTopic)
|
|
|
|
proc unsubscribe*(self: Waku, contentTopic: ContentTopic): Result[void, string] =
|
|
## Unsubscribes from `contentTopic`, resolving its shard via autosharding.
|
|
return self.node.subscriptionManager.unsubscribe(contentTopic)
|
|
|
|
proc isSubscribed*(self: Waku, contentTopic: ContentTopic): Result[bool, string] =
|
|
## True if the node already subscribes to `contentTopic`.
|
|
return self.node.subscriptionManager.isSubscribed(contentTopic)
|