mirror of https://github.com/waku-org/nwaku.git
fix(rln-relay): remove dependency on applications' configuration
This commit is contained in:
parent
bcc6c32287
commit
b4bda3c10b
|
@ -542,7 +542,21 @@ proc processInput(rfd: AsyncFD) {.async.} =
|
|||
echo "You are registered to the rln membership contract, find details of your registration transaction in https://goerli.etherscan.io/tx/0x", txHash
|
||||
|
||||
echo "rln-relay preparation is in progress..."
|
||||
let res = await node.mountRlnRelay(conf = conf, spamHandler = some(spamHandler), registrationHandler = some(registrationHandler))
|
||||
|
||||
let rlnConf = WakuRlnConfig(
|
||||
rlnRelayDynamic: conf.rlnRelayDynamic,
|
||||
rlnRelayPubsubTopic: conf.rlnRelayPubsubTopic,
|
||||
rlnRelayContentTopic: conf.rlnRelayContentTopic,
|
||||
rlnRelayMembershipIndex: conf.rlnRelayMembershipIndex,
|
||||
rlnRelayEthContractAddress: conf.rlnRelayEthContractAddress,
|
||||
rlnRelayEthClientAddress: conf.rlnRelayEthClientAddress,
|
||||
rlnRelayEthAccountPrivateKey: conf.rlnRelayEthAccountPrivateKey,
|
||||
rlnRelayEthAccountAddress: conf.rlnRelayEthAccountAddress,
|
||||
rlnRelayCredPath: conf.rlnRelayCredPath,
|
||||
rlnRelayCredentialsPassword: conf.rlnRelayCredentialsPassword
|
||||
)
|
||||
|
||||
let res = await node.mountRlnRelay(conf=rlnConf, spamHandler = some(spamHandler), registrationHandler = some(registrationHandler))
|
||||
if res.isErr():
|
||||
echo "failed to mount rln-relay: " & res.error()
|
||||
else:
|
||||
|
|
|
@ -358,8 +358,22 @@ proc setupProtocols(node: WakuNode, conf: WakuNodeConf,
|
|||
|
||||
when defined(rln) or defined(rlnzerokit):
|
||||
if conf.rlnRelay:
|
||||
|
||||
let rlnConf = WakuRlnConfig(
|
||||
rlnRelayDynamic: conf.rlnRelayDynamic,
|
||||
rlnRelayPubsubTopic: conf.rlnRelayPubsubTopic,
|
||||
rlnRelayContentTopic: conf.rlnRelayContentTopic,
|
||||
rlnRelayMembershipIndex: conf.rlnRelayMembershipIndex,
|
||||
rlnRelayEthContractAddress: conf.rlnRelayEthContractAddress,
|
||||
rlnRelayEthClientAddress: conf.rlnRelayEthClientAddress,
|
||||
rlnRelayEthAccountPrivateKey: conf.rlnRelayEthAccountPrivateKey,
|
||||
rlnRelayEthAccountAddress: conf.rlnRelayEthAccountAddress,
|
||||
rlnRelayCredPath: conf.rlnRelayCredPath,
|
||||
rlnRelayCredentialsPassword: conf.rlnRelayCredentialsPassword
|
||||
)
|
||||
|
||||
try:
|
||||
let res = await node.mountRlnRelay(conf)
|
||||
let res = await node.mountRlnRelay(rlnConf)
|
||||
if res.isErr():
|
||||
return err("failed to mount waku RLN relay protocol: " & res.error)
|
||||
except:
|
||||
|
|
|
@ -20,9 +20,7 @@ import
|
|||
waku_rln_relay_metrics,
|
||||
../../utils/time,
|
||||
../../utils/keyfile,
|
||||
../../node/waku_node,
|
||||
../../../../../apps/wakunode2/config, ## TODO: Decouple the protocol code from the app configuration
|
||||
../../../../../apps/chat2/config_chat2, ## TODO: Decouple the protocol code from the app configuration
|
||||
../../node/waku_node,
|
||||
../waku_message
|
||||
|
||||
logScope:
|
||||
|
@ -1284,8 +1282,21 @@ proc readRlnCredentials*(path: string,
|
|||
return err("Error while loading keyfile for RLN credentials at " & path)
|
||||
|
||||
|
||||
type WakuRlnConfig* = object
|
||||
rlnRelayDynamic*: bool
|
||||
rlnRelayPubsubTopic*: PubsubTopic
|
||||
rlnRelayContentTopic*: ContentTopic
|
||||
rlnRelayMembershipIndex*: uint
|
||||
rlnRelayEthContractAddress*: string
|
||||
rlnRelayEthClientAddress*: string
|
||||
rlnRelayEthAccountPrivateKey*: string
|
||||
rlnRelayEthAccountAddress*: string
|
||||
rlnRelayCredPath*: string
|
||||
rlnRelayCredentialsPassword*: string
|
||||
|
||||
|
||||
proc mount(node: WakuNode,
|
||||
conf: WakuNodeConf|Chat2Conf,
|
||||
conf: WakuRlnConfig,
|
||||
spamHandler: Option[SpamHandler] = none(SpamHandler),
|
||||
registrationHandler: Option[RegistrationHandler] = none(RegistrationHandler)
|
||||
): Future[RlnRelayResult[void]] {.async.} =
|
||||
|
@ -1431,7 +1442,7 @@ proc mount(node: WakuNode,
|
|||
|
||||
|
||||
proc mountRlnRelay*(node: WakuNode,
|
||||
conf: WakuNodeConf|Chat2Conf,
|
||||
conf: WakuRlnConfig,
|
||||
spamHandler: Option[SpamHandler] = none(SpamHandler),
|
||||
registrationHandler: Option[RegistrationHandler] = none(RegistrationHandler)
|
||||
): Future[RlnRelayResult[void]] {.async.} =
|
||||
|
|
Loading…
Reference in New Issue