Tanya S cbb601ec9f
chore: phase 4 — remove RLN proof generation from lightpush server to client (#4009)
* remove RLN proof generation from lightpush server to client

* set timestamp before generating lightpush msg proof

* Add explicit error message for checkAndGenerateRLNProof and oneline for ensureTimestampSet

* Change ensureTimestampSet from func to proc
2026-07-01 14:02:07 +02:00

30 lines
1.1 KiB
Nim

import logos_delivery/waku/compat/option_valueor
{.push raises: [].}
import results
import ../waku_core, ../waku_relay, ./common, ../rln, ../rln/protocol_types
import std/times, libp2p/peerid, stew/byteutils
proc getNilPushHandler*(): PushMessageHandler =
return proc(
pubsubTopic: string, message: WakuMessage
): Future[WakuLightPushResult] {.async.} =
return lightpushResultInternalError("no waku relay found")
proc getRelayPushHandler*(wakuRelay: WakuRelay): PushMessageHandler =
return proc(
pubsubTopic: string, message: WakuMessage
): Future[WakuLightPushResult] {.async.} =
(await wakuRelay.validateMessage(pubSubTopic, message)).isOkOr:
return lighpushErrorResult(LightPushErrorCode.INVALID_MESSAGE, $error)
let publishedResult = (await wakuRelay.publish(pubsubTopic, message)).valueOr:
let msgHash = computeMessageHash(pubsubTopic, message).to0xHex()
notice "Lightpush request has not been published to any peers",
msg_hash = msgHash, reason = $error
return mapPubishingErrorToPushResult(error)
return lightpushSuccessResult(publishedResult.uint32)