Adds rln-relay flag (#347)

* adds rlnrelay flag

* minor edit

* adds the input name
This commit is contained in:
Sanaz Taheri Boshrooyeh 2021-01-08 09:56:58 -08:00 committed by GitHub
parent 96f95ed0b6
commit cc1fc15d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 5 deletions

View File

@ -23,7 +23,7 @@ proc runBackground() {.async.} =
Port(uint16(conf.tcpPort) + conf.portsShift), extIp, extTcpPort)
await node.start()
await node.mountRelay()
await node.mountRelay(rlnRelayEnabled = conf.rlnrelay)
# Subscribe to a topic
let topic = cast[Topic]("foobar")

View File

@ -192,9 +192,9 @@ proc processInput(rfd: AsyncFD, rng: ref BrHmacDrbgContext) {.async.} =
await node.start()
if conf.filternode != "":
await node.mountRelay(conf.topics.split(" "))
await node.mountRelay(conf.topics.split(" "), rlnRelayEnabled = conf.rlnrelay)
else:
await node.mountRelay(@[])
await node.mountRelay(@[], rlnRelayEnabled = conf.rlnrelay)
var chat = Chat(node: node, transp: transp, subscribed: true, connected: false, started: true)

View File

@ -62,6 +62,11 @@ type
desc: "Flag whether to start relay protocol",
defaultValue: true
name: "relay" }: bool
rlnrelay* {.
desc: "Flag whether to enable spam protection through rln-relay",
defaultValue: false
name: "rlnrelay" }: bool
swap* {.
desc: "Flag whether to start swap protocol",

View File

@ -296,7 +296,7 @@ proc mountStore*(node: WakuNode, store: MessageStore = nil) =
node.switch.mount(node.wakuStore)
node.subscriptions.subscribe(WakuStoreCodec, node.wakuStore.subscription())
proc mountRelay*(node: WakuNode, topics: seq[string] = newSeq[string]()) {.async, gcsafe.} =
proc mountRelay*(node: WakuNode, topics: seq[string] = newSeq[string](), rlnRelayEnabled: bool = false) {.async, gcsafe.} =
# TODO add the RLN registration
let wakuRelay = WakuRelay.init(
switch = node.switch,
@ -306,6 +306,13 @@ proc mountRelay*(node: WakuNode, topics: seq[string] = newSeq[string]()) {.async
sign = false,
verifySignature = false
)
# TODO if rln-relay enabled, then perform registration
if rlnRelayEnabled:
debug "Using WakuRLNRelay"
else:
debug "WakuRLNRelay is disabled"
node.wakuRelay = wakuRelay
node.switch.mount(wakuRelay)
@ -478,7 +485,7 @@ when isMainModule:
mountFilter(node)
if conf.relay:
waitFor mountRelay(node, conf.topics.split(" "))
waitFor mountRelay(node, conf.topics.split(" "), rlnRelayEnabled = conf.rlnrelay)
if conf.staticnodes.len > 0:
waitFor connectToNodes(node, conf.staticnodes)