mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-22 12:39:30 +00:00
* change all usage of std.options.Option[T] to results.Opt[T] * fix broken apps and examples (to validate refactor) * removed all std/options code added for libp2p v2 migration * add broker Opt codec to persistency/backend_comm.nim * add a readValue overload for Opt[T] in tools/confutils/cli_args.nim * keep Option where required (Presto, confutils' config_file.nim) * Change generateRlnProof error handling * Fix imports
37 lines
1.0 KiB
Nim
37 lines
1.0 KiB
Nim
## Waku layer API — lightpush (light client publish) operations.
|
|
{.push raises: [].}
|
|
|
|
import results, chronos, chronicles
|
|
|
|
import logos_delivery/waku/waku
|
|
import
|
|
logos_delivery/waku/[
|
|
waku_core,
|
|
waku_core/codecs,
|
|
node/waku_node,
|
|
node/peer_manager,
|
|
waku_lightpush_legacy/client,
|
|
]
|
|
|
|
proc lightpushPublish*(
|
|
self: Waku, pubsubTopic: PubsubTopic, message: WakuMessage
|
|
): Future[Result[string, string]] {.async.} =
|
|
## Selects a lightpush service peer and publishes; returns the message hash.
|
|
try:
|
|
if self.node.wakuLegacyLightpushClient.isNil():
|
|
return err("wakuLegacyLightpushClient is not mounted")
|
|
|
|
let remotePeer = self.node.peerManager.selectPeer(WakuLightPushCodec).valueOr:
|
|
return err("failed to lightpublish message, no suitable remote peers")
|
|
|
|
let msgHashHex = (
|
|
await self.node.wakuLegacyLightpushClient.publish(
|
|
pubsubTopic, message, remotePeer
|
|
)
|
|
).valueOr:
|
|
return err($error)
|
|
|
|
return ok(msgHashHex)
|
|
except CatchableError as e:
|
|
return err(e.msg)
|