Skip to content

Commit

Permalink
test(rln-relay): rpc handler to support waku rln relay (#1852)
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Aug 16, 2023
1 parent fc604ca commit 8bcb0ac
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion waku/node/jsonrpc/relay/handlers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ import
../../message_cache,
../message

from std/times import getTime
from std/times import toUnix

when defined(rln):
import
../../../waku_rln_relay

logScope:
topics = "waku node jsonrpc relay_api"

Expand Down Expand Up @@ -77,14 +84,21 @@ proc installRelayApiHandlers*(node: WakuNode, server: RpcServer, cache: MessageC
if payloadRes.isErr():
raise newException(ValueError, "invalid payload format: " & payloadRes.error)

let message = WakuMessage(
var message = WakuMessage(
payload: payloadRes.value,
# TODO: Fail if the message doesn't have a content topic
contentTopic: msg.contentTopic.get(DefaultContentTopic),
version: msg.version.get(0'u32),
timestamp: msg.timestamp.get(Timestamp(0)),
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)

Expand Down

0 comments on commit 8bcb0ac

Please sign in to comment.