mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-07-01 05:49:36 +00:00
`SendService`/`RecvService` took a raw `WakuNode` and reached into its internals (`wakuStoreClient`, `subscriptionManager`, `peerManager`), which breaks the layering: the messaging layer should depend on the Waku kernel, not the node. Widen the Waku api surface with the operations these services need (`storeQueryToAny`, `isStoreMounted`, `hasStorePeer`, `isContentSubscribed`, `subscribedContentTopics`) and switch both services to hold `Waku` and call that surface instead. The send-processor chain still pulls raw publish handles (relay/lightpush/RLN/peer manager) from `waku.node`, since the kernel API does not expose publishing primitives yet; this is isolated to the constructor and flagged with a comment. Also make `MessagingClient.new` return explicitly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 lines
1.7 KiB
Nim
38 lines
1.7 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 std/sets
|
|
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)
|
|
|
|
proc isContentSubscribed*(
|
|
self: Waku, shard: PubsubTopic, contentTopic: ContentTopic
|
|
): bool =
|
|
## True if `contentTopic` is subscribed on the given `shard` (pubsub topic).
|
|
return self.node.subscriptionManager.isContentSubscribed(shard, contentTopic)
|
|
|
|
proc subscribedContentTopics*(self: Waku): seq[(PubsubTopic, HashSet[ContentTopic])] =
|
|
## Snapshot of every shard with its non-empty content-topic set.
|
|
var res: seq[(PubsubTopic, HashSet[ContentTopic])]
|
|
for shard, contentTopics in self.node.subscriptionManager.subscribedContentTopics:
|
|
res.add((shard, contentTopics))
|
|
return res
|