mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 05:53:11 +00:00
updated libwaku API to integrate with logos chat poc for mix integration
This commit is contained in:
parent
96196ab8bc
commit
dc0ebc7142
@ -47,8 +47,10 @@ proc waku_filter_subscribe(
|
||||
error "fail filter subscribe", error = errorMsg
|
||||
return err(errorMsg)
|
||||
|
||||
let pubsubTopicOpt =
|
||||
if ($pubsubTopic).len > 0: some(PubsubTopic($pubsubTopic)) else: none(PubsubTopic)
|
||||
let subFut = ctx.myLib[].node.filterSubscribe(
|
||||
some(PubsubTopic($pubsubTopic)),
|
||||
pubsubTopicOpt,
|
||||
($contentTopics).split(",").mapIt(ContentTopic(it)),
|
||||
peer,
|
||||
)
|
||||
|
||||
@ -39,13 +39,15 @@ proc waku_lightpush_publish(
|
||||
let errorMsg = "failed to lightpublish message, no suitable remote peers"
|
||||
error "PUBLISH failed", error = errorMsg
|
||||
return err(errorMsg)
|
||||
let topic =
|
||||
if ($pubsubTopic).len == 0:
|
||||
none(PubsubTopic)
|
||||
else:
|
||||
some(PubsubTopic($pubsubTopic))
|
||||
|
||||
let msgHashHex = (
|
||||
await ctx.myLib[].node.wakuLegacyLightpushClient.publish(
|
||||
$pubsubTopic, msg, peer = peerOpt.get()
|
||||
)
|
||||
).valueOr:
|
||||
error "PUBLISH failed", error = error
|
||||
return err($error)
|
||||
discard (await ctx.myLib[].node.lightpushPublish(topic, msg, peerOpt)).valueOr:
|
||||
let errorMsg = error.desc.get($error.code.int)
|
||||
error "PUBLISH failed", error = errorMsg
|
||||
return err(errorMsg)
|
||||
|
||||
return ok(msgHashHex)
|
||||
return ok("")
|
||||
|
||||
@ -246,23 +246,27 @@ proc lightpushPublish*(
|
||||
return lighpushErrorResult(
|
||||
LightPushErrorCode.SERVICE_NOT_AVAILABLE, "Waku lightpush not available"
|
||||
)
|
||||
if mixify and node.wakuMix.isNil():
|
||||
error "failed to publish message using mix as mix protocol is not mounted"
|
||||
var lmixify = mixify
|
||||
if not node.wakuMix.isNil():
|
||||
lmixify = true
|
||||
|
||||
let
|
||||
#[ error "failed to publish message using mix as mix protocol is not mounted"
|
||||
return lighpushErrorResult(
|
||||
LightPushErrorCode.SERVICE_NOT_AVAILABLE, "Waku lightpush with mix not available"
|
||||
)
|
||||
let toPeer: RemotePeerInfo = peerOpt.valueOr:
|
||||
if not node.wakuLightPush.isNil():
|
||||
RemotePeerInfo.init(node.peerId())
|
||||
elif not node.wakuLightpushClient.isNil():
|
||||
node.peerManager.selectPeer(WakuLightPushCodec).valueOr:
|
||||
let msg = "no suitable remote peers"
|
||||
error "failed to publish message", msg = msg
|
||||
return lighpushErrorResult(LightPushErrorCode.NO_PEERS_TO_RELAY, msg)
|
||||
else:
|
||||
return lighpushErrorResult(
|
||||
LightPushErrorCode.NO_PEERS_TO_RELAY, "no suitable remote peers"
|
||||
)
|
||||
) ]#
|
||||
toPeer: RemotePeerInfo = peerOpt.valueOr:
|
||||
if not node.wakuLightPush.isNil():
|
||||
RemotePeerInfo.init(node.peerId())
|
||||
elif not node.wakuLightpushClient.isNil():
|
||||
node.peerManager.selectPeer(WakuLightPushCodec).valueOr:
|
||||
let msg = "no suitable remote peers"
|
||||
error "failed to publish message", msg = msg
|
||||
return lighpushErrorResult(LightPushErrorCode.NO_PEERS_TO_RELAY, msg)
|
||||
else:
|
||||
return lighpushErrorResult(
|
||||
LightPushErrorCode.NO_PEERS_TO_RELAY, "no suitable remote peers"
|
||||
)
|
||||
|
||||
let pubsubForPublish = pubSubTopic.valueOr:
|
||||
if node.wakuAutoSharding.isNone():
|
||||
@ -280,4 +284,4 @@ proc lightpushPublish*(
|
||||
error "lightpush publish error", error = msg
|
||||
return lighpushErrorResult(LightPushErrorCode.INTERNAL_SERVER_ERROR, msg)
|
||||
|
||||
return await lightpushPublishHandler(node, pubsubForPublish, message, toPeer, mixify)
|
||||
return await lightpushPublishHandler(node, pubsubForPublish, message, toPeer, lmixify)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user