Skip to content

Commit

Permalink
feat: validate rln relay config when mounting
Browse files Browse the repository at this point in the history
Fails faster when ethereum client address is not passed.
  • Loading branch information
fryorcraken committed Jul 15, 2024
1 parent 558c3d7 commit ae7f07b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions waku/node/waku_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,11 @@ proc mountRlnRelay*(
) {.async.} =
info "mounting rln relay"

let validationRes = rlnConf.validate()
if validationRes.isErr():
echo "it is ERR"
raise newException(CatchableError, validationRes.error)

if node.wakuRelay.isNil():
raise newException(
CatchableError, "WakuRelay protocol is not mounted, cannot mount WakuRlnRelay"
Expand Down
5 changes: 5 additions & 0 deletions waku/waku_rln_relay/rln_relay.nim
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ type WakuRlnConfig* = object
onFatalErrorAction*: OnFatalErrorHandler
rlnRelayUserMessageLimit*: uint64

proc validate*(rlnConfig: WakuRlnConfig): Result[void, string] =
if rlnConfig.rlnRelayEthClientAddress == "":
return err("Rln Relay Eth Client address must be specified")
ok()

proc createMembershipList*(
rln: ptr RLN, n: int
): RlnRelayResult[(seq[RawMembershipCredentials], string)] =
Expand Down

0 comments on commit ae7f07b

Please sign in to comment.