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) Port(uint16(conf.tcpPort) + conf.portsShift), extIp, extTcpPort)
await node.start() await node.start()
await node.mountRelay() await node.mountRelay(rlnRelayEnabled = conf.rlnrelay)
# Subscribe to a topic # Subscribe to a topic
let topic = cast[Topic]("foobar") let topic = cast[Topic]("foobar")

View File

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

View File

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

View File

@ -296,7 +296,7 @@ proc mountStore*(node: WakuNode, store: MessageStore = nil) =
node.switch.mount(node.wakuStore) node.switch.mount(node.wakuStore)
node.subscriptions.subscribe(WakuStoreCodec, node.wakuStore.subscription()) 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 # TODO add the RLN registration
let wakuRelay = WakuRelay.init( let wakuRelay = WakuRelay.init(
switch = node.switch, switch = node.switch,
@ -306,6 +306,13 @@ proc mountRelay*(node: WakuNode, topics: seq[string] = newSeq[string]()) {.async
sign = false, sign = false,
verifySignature = 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.wakuRelay = wakuRelay
node.switch.mount(wakuRelay) node.switch.mount(wakuRelay)
@ -478,7 +485,7 @@ when isMainModule:
mountFilter(node) mountFilter(node)
if conf.relay: if conf.relay:
waitFor mountRelay(node, conf.topics.split(" ")) waitFor mountRelay(node, conf.topics.split(" "), rlnRelayEnabled = conf.rlnrelay)
if conf.staticnodes.len > 0: if conf.staticnodes.len > 0:
waitFor connectToNodes(node, conf.staticnodes) waitFor connectToNodes(node, conf.staticnodes)