mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 14:03:06 +00:00
* Upgrade lpt to new config methods * Make choice of legacy and v3 lightpush configurable on cli * Adjust runner script to allow easy lightpush version selection * Prepare selectable lightpush for infra env runs * Fix misused result vs return * Fixes and more explanatory comments added * Fix ~pure virtual~ notice to =discard
25 lines
771 B
Nim
25 lines
771 B
Nim
import chronos, results, options
|
|
import waku/[waku_node, waku_core]
|
|
import publisher_base
|
|
|
|
type LegacyPublisher* = ref object of PublisherBase
|
|
|
|
proc new*(T: type LegacyPublisher, wakuNode: WakuNode): T =
|
|
if isNil(wakuNode.wakuLegacyLightpushClient):
|
|
wakuNode.mountLegacyLightPushClient()
|
|
|
|
return LegacyPublisher(wakuNode: wakuNode)
|
|
|
|
method send*(
|
|
self: LegacyPublisher,
|
|
topic: PubsubTopic,
|
|
message: WakuMessage,
|
|
servicePeer: RemotePeerInfo,
|
|
): Future[Result[void, string]] {.async.} =
|
|
# when error it must return original error desc due the text is used for distinction between error types in metrics.
|
|
discard (
|
|
await self.wakuNode.legacyLightpushPublish(some(topic), message, servicePeer)
|
|
).valueOr:
|
|
return err(error)
|
|
return ok()
|