2026-06-25 11:54:47 +02:00
|
|
|
proc relay_get_peers_in_mesh*(
|
|
|
|
|
self: LogosDelivery, pubsubTopic: string
|
|
|
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
|
|
|
let peers = (await self.waku.relayPeersInMesh(PubsubTopic(pubsubTopic))).valueOr:
|
2026-06-25 00:40:02 +02:00
|
|
|
return err(error)
|
|
|
|
|
return ok(peers.join(","))
|
2025-12-19 17:00:43 +01:00
|
|
|
|
2026-06-25 11:54:47 +02:00
|
|
|
proc relay_get_num_peers_in_mesh*(
|
|
|
|
|
self: LogosDelivery, pubsubTopic: string
|
|
|
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
|
|
|
let n = (await self.waku.relayNumPeersInMesh(PubsubTopic(pubsubTopic))).valueOr:
|
2026-06-25 00:40:02 +02:00
|
|
|
return err(error)
|
|
|
|
|
return ok($n)
|
2025-12-19 17:00:43 +01:00
|
|
|
|
2026-06-25 11:54:47 +02:00
|
|
|
proc relay_get_connected_peers*(
|
|
|
|
|
self: LogosDelivery, pubsubTopic: string
|
|
|
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
|
|
|
let peers = (await self.waku.relayConnectedPeers(PubsubTopic(pubsubTopic))).valueOr:
|
2026-06-25 00:40:02 +02:00
|
|
|
return err(error)
|
|
|
|
|
return ok(peers.join(","))
|
2025-12-19 17:00:43 +01:00
|
|
|
|
2026-06-25 11:54:47 +02:00
|
|
|
proc relay_get_num_connected_peers*(
|
|
|
|
|
self: LogosDelivery, pubsubTopic: string
|
|
|
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
|
|
|
let n = (await self.waku.relayNumConnectedPeers(PubsubTopic(pubsubTopic))).valueOr:
|
2026-06-25 00:40:02 +02:00
|
|
|
return err(error)
|
|
|
|
|
return ok($n)
|
2025-12-19 17:00:43 +01:00
|
|
|
|
2026-06-25 11:54:47 +02:00
|
|
|
proc relay_add_protected_shard*(
|
|
|
|
|
self: LogosDelivery, clusterId: uint16, shardId: uint16, publicKey: string
|
|
|
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
|
|
|
(await self.waku.relayAddProtectedShard(clusterId, shardId, publicKey)).isOkOr:
|
2026-06-25 00:40:02 +02:00
|
|
|
return err(error)
|
2025-12-19 17:00:43 +01:00
|
|
|
return ok("")
|
|
|
|
|
|
2026-06-25 11:54:47 +02:00
|
|
|
proc relay_subscribe*(
|
|
|
|
|
self: LogosDelivery, pubsubTopic: string
|
|
|
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
|
|
|
# Just establishes the subscription; delivery flows through the global
|
|
|
|
|
# MessageSeenEvent listener (see the ctor in liblogosdelivery.nim).
|
|
|
|
|
(await self.waku.relaySubscribe(PubsubTopic(pubsubTopic))).isOkOr:
|
2026-06-25 00:40:02 +02:00
|
|
|
return err(error)
|
2025-12-19 17:00:43 +01:00
|
|
|
return ok("")
|
|
|
|
|
|
2026-06-25 11:54:47 +02:00
|
|
|
proc relay_unsubscribe*(
|
|
|
|
|
self: LogosDelivery, pubsubTopic: string
|
|
|
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
|
|
|
(await self.waku.relayUnsubscribe(PubsubTopic(pubsubTopic))).isOkOr:
|
2026-06-25 00:40:02 +02:00
|
|
|
return err(error)
|
2025-12-19 17:00:43 +01:00
|
|
|
return ok("")
|
|
|
|
|
|
2026-06-25 11:54:47 +02:00
|
|
|
proc relay_publish*(
|
|
|
|
|
self: LogosDelivery, pubsubTopic: string, message: WakuMessage, timeoutMs: uint32
|
|
|
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
|
|
|
## Returns the published message hash (0x-hex).
|
|
|
|
|
let hash = (
|
|
|
|
|
await self.waku.relayPublish(PubsubTopic(pubsubTopic), message, timeoutMs)
|
2026-06-25 00:40:02 +02:00
|
|
|
).valueOr:
|
|
|
|
|
return err(error)
|
2026-06-25 11:54:47 +02:00
|
|
|
return ok(hash)
|
2025-12-19 17:00:43 +01:00
|
|
|
|
2026-06-25 11:54:47 +02:00
|
|
|
proc relay_default_pubsub_topic*(
|
|
|
|
|
self: LogosDelivery
|
|
|
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
|
|
|
return ok(string(self.waku.defaultPubsubTopic()))
|
2025-12-19 17:00:43 +01:00
|
|
|
|
2026-06-25 11:54:47 +02:00
|
|
|
proc relay_content_topic*(
|
|
|
|
|
self: LogosDelivery,
|
|
|
|
|
appName: string,
|
|
|
|
|
appVersion: uint32,
|
|
|
|
|
contentTopicName: string,
|
|
|
|
|
encoding: string,
|
|
|
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
|
|
|
let contentTopic = self.waku.buildContentTopic(
|
|
|
|
|
appName, appVersion, contentTopicName, encoding
|
2026-06-25 00:40:02 +02:00
|
|
|
).valueOr:
|
|
|
|
|
return err(error)
|
2026-06-25 11:54:47 +02:00
|
|
|
return ok(string(contentTopic))
|
2025-12-19 17:00:43 +01:00
|
|
|
|
2026-06-25 11:54:47 +02:00
|
|
|
proc relay_pubsub_topic*(
|
|
|
|
|
self: LogosDelivery, topicName: string
|
|
|
|
|
): Future[Result[string, string]] {.ffi.} =
|
|
|
|
|
let pubsubTopic = self.waku.buildPubsubTopic(topicName).valueOr:
|
2026-06-25 00:40:02 +02:00
|
|
|
return err(error)
|
2026-06-25 11:54:47 +02:00
|
|
|
return ok(string(pubsubTopic))
|