diff --git a/examples/v2/basic2.nim b/examples/v2/basic2.nim index 1deddcbb3..328fad69f 100644 --- a/examples/v2/basic2.nim +++ b/examples/v2/basic2.nim @@ -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") diff --git a/examples/v2/chat2.nim b/examples/v2/chat2.nim index e0be4071e..e7d2adcd5 100644 --- a/examples/v2/chat2.nim +++ b/examples/v2/chat2.nim @@ -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) diff --git a/waku/v2/node/config.nim b/waku/v2/node/config.nim index e20799792..808769dc9 100644 --- a/waku/v2/node/config.nim +++ b/waku/v2/node/config.nim @@ -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", diff --git a/waku/v2/node/wakunode2.nim b/waku/v2/node/wakunode2.nim index 198582380..b1506dde9 100644 --- a/waku/v2/node/wakunode2.nim +++ b/waku/v2/node/wakunode2.nim @@ -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)