From 493f082975e7b1bef231acf0299453d645388b8e Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Fri, 12 May 2023 12:27:49 +0200 Subject: [PATCH 1/2] wakunode2 config. adding new 'topic' config parameter. This new parameter can be repeated and we are starting to deprecate the parameter 'topics', that expected to receive a space-separated list of pubsubtopic to subscribe to. --- apps/wakunode2/app.nim | 11 ++++++++++- apps/wakunode2/config.nim | 13 ++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/apps/wakunode2/app.nim b/apps/wakunode2/app.nim index 6e111c84cb..3b0af1d77f 100644 --- a/apps/wakunode2/app.nim +++ b/apps/wakunode2/app.nim @@ -547,7 +547,16 @@ proc setupProtocols(node: WakuNode, conf: WakuNodeConf, peerExchangeHandler = some(handlePeerExchange) if conf.relay: - let pubsubTopics = conf.topics.split(" ") + + var pubsubTopics = @[""] + if conf.topicsDeprecated != "": + if conf.topics != @["/waku/2/default-waku/proto"]: + return err("Please don't specify 'topics' and 'topic' simultaneously. Only use the 'topic' parameter") + + # This clause (if conf.topicsDeprecated != "") should disapear in >= v0.18.0 + pubsubTopics = conf.topicsDeprecated.split(" ") + else: + pubsubTopics = conf.topics try: await mountRelay(node, pubsubTopics, peerExchangeHandler = peerExchangeHandler) except CatchableError: diff --git a/apps/wakunode2/config.nim b/apps/wakunode2/config.nim index fe513fea4d..f9c1d051b6 100644 --- a/apps/wakunode2/config.nim +++ b/apps/wakunode2/config.nim @@ -42,7 +42,6 @@ type defaultValue: newSeq[ProtectedTopic](0) name: "protected-topic" .}: seq[ProtectedTopic] - ## Log configuration logLevel* {. desc: "Sets the log level for process. Supported levels: TRACE, DEBUG, INFO, NOTICE, WARN, ERROR or FATAL", @@ -54,7 +53,6 @@ type defaultValue: logging.LogFormat.TEXT, name: "log-format" .}: logging.LogFormat - ## General node config agentString* {. defaultValue: "nwaku", @@ -207,11 +205,16 @@ type defaultValue: false name: "keep-alive" }: bool - topics* {. - desc: "Default topics to subscribe to (space separated list)." - defaultValue: "/waku/2/default-waku/proto" + topicsDeprecated* {. + desc: "Default topics to subscribe to (space separated list). DEPRECATED: please use repeated --topic argument instead." + defaultValue: "" name: "topics" .}: string + topics* {. + desc: "Default topic to subscribe to. Argument may be repeated." + defaultValue: @["/waku/2/default-waku/proto"] + name: "topic" .}: seq[string] + ## Store and message store config store* {. From 339e4d5d34dd1344e32107720b2267ec8d81806d Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Fri, 12 May 2023 13:06:53 +0200 Subject: [PATCH 2/2] Appying PR suggestions --- apps/wakunode2/app.nim | 5 +++-- apps/wakunode2/config.nim | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/wakunode2/app.nim b/apps/wakunode2/app.nim index 3b0af1d77f..9e5e84b00f 100644 --- a/apps/wakunode2/app.nim +++ b/apps/wakunode2/app.nim @@ -549,11 +549,12 @@ proc setupProtocols(node: WakuNode, conf: WakuNodeConf, if conf.relay: var pubsubTopics = @[""] - if conf.topicsDeprecated != "": + if conf.topicsDeprecated != "/waku/2/default-waku/proto": + warn "The 'topics' parameter is deprecated. Better use the 'topic' one instead." if conf.topics != @["/waku/2/default-waku/proto"]: return err("Please don't specify 'topics' and 'topic' simultaneously. Only use the 'topic' parameter") - # This clause (if conf.topicsDeprecated != "") should disapear in >= v0.18.0 + # This clause (if conf.topicsDeprecated ) should disapear in >= v0.18.0 pubsubTopics = conf.topicsDeprecated.split(" ") else: pubsubTopics = conf.topics diff --git a/apps/wakunode2/config.nim b/apps/wakunode2/config.nim index f9c1d051b6..aba56ba917 100644 --- a/apps/wakunode2/config.nim +++ b/apps/wakunode2/config.nim @@ -207,7 +207,7 @@ type topicsDeprecated* {. desc: "Default topics to subscribe to (space separated list). DEPRECATED: please use repeated --topic argument instead." - defaultValue: "" + defaultValue: "/waku/2/default-waku/proto" name: "topics" .}: string topics* {.