mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-14 17:04:53 +00:00
test(rln-relay): rpc handler to support waku rln relay (#1852)
This commit is contained in:
parent
fc604ca5f6
commit
8bcb0acf1a
@ -17,6 +17,13 @@ import
|
|||||||
../../message_cache,
|
../../message_cache,
|
||||||
../message
|
../message
|
||||||
|
|
||||||
|
from std/times import getTime
|
||||||
|
from std/times import toUnix
|
||||||
|
|
||||||
|
when defined(rln):
|
||||||
|
import
|
||||||
|
../../../waku_rln_relay
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "waku node jsonrpc relay_api"
|
topics = "waku node jsonrpc relay_api"
|
||||||
|
|
||||||
@ -77,7 +84,7 @@ proc installRelayApiHandlers*(node: WakuNode, server: RpcServer, cache: MessageC
|
|||||||
if payloadRes.isErr():
|
if payloadRes.isErr():
|
||||||
raise newException(ValueError, "invalid payload format: " & payloadRes.error)
|
raise newException(ValueError, "invalid payload format: " & payloadRes.error)
|
||||||
|
|
||||||
let message = WakuMessage(
|
var message = WakuMessage(
|
||||||
payload: payloadRes.value,
|
payload: payloadRes.value,
|
||||||
# TODO: Fail if the message doesn't have a content topic
|
# TODO: Fail if the message doesn't have a content topic
|
||||||
contentTopic: msg.contentTopic.get(DefaultContentTopic),
|
contentTopic: msg.contentTopic.get(DefaultContentTopic),
|
||||||
@ -85,6 +92,13 @@ proc installRelayApiHandlers*(node: WakuNode, server: RpcServer, cache: MessageC
|
|||||||
timestamp: msg.timestamp.get(Timestamp(0)),
|
timestamp: msg.timestamp.get(Timestamp(0)),
|
||||||
ephemeral: msg.ephemeral.get(false)
|
ephemeral: msg.ephemeral.get(false)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
when defined(rln):
|
||||||
|
if not node.wakuRlnRelay.isNil():
|
||||||
|
let success = node.wakuRlnRelay.appendRLNProof(message,
|
||||||
|
float64(getTime().toUnix()))
|
||||||
|
if not success:
|
||||||
|
raise newException(ValueError, "Failed to append RLN proof to message")
|
||||||
|
|
||||||
let publishFut = node.publish(topic, message)
|
let publishFut = node.publish(topic, message)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user