feat: validate rln relay config when mounting

Fails faster when ethereum client address is not passed.
This commit is contained in:
fryorcraken 2024-07-12 16:08:37 +10:00 committed by fryorcraken
parent 79b0e2e023
commit 6251dddae2
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 10 additions and 0 deletions

View File

@ -1123,6 +1123,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"

View File

@ -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)] =