From 3e39a2343a09d1260f43649dbaa889e42ebaf707 Mon Sep 17 00:00:00 2001 From: fryorcraken Date: Fri, 28 Jun 2024 21:36:00 +1000 Subject: [PATCH] feat: propose `preset` option instead of deducing from cluster-id --- waku/factory/external_config.nim | 10 +++++++++- waku/factory/waku.nim | 13 +++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/waku/factory/external_config.nim b/waku/factory/external_config.nim index 882e6d4d95..cd0db374ee 100644 --- a/waku/factory/external_config.nim +++ b/waku/factory/external_config.nim @@ -127,6 +127,12 @@ type WakuNodeConf* = object .}: seq[ProtectedTopic] ## General node config + preset* {. + desc: "Network preset to use." & "Must be one of 'default'", + defaultValue: "default", + name: "preset" + .}: string + clusterId* {. desc: "Cluster id that the node is running in. Node in a different cluster id is disconnected.", @@ -253,7 +259,9 @@ type WakuNodeConf* = object .}: seq[string] shards* {. - desc: "Shards index to subscribe to [0.." & $MaxShardIndex & "]. Argument may be repeated.", + desc: + "Shards index to subscribe to [0.." & $MaxShardIndex & + "]. Argument may be repeated.", defaultValue: @[], name: "shard" .}: seq[uint16] diff --git a/waku/factory/waku.nim b/waku/factory/waku.nim index 3c88620935..5686c0f717 100644 --- a/waku/factory/waku.nim +++ b/waku/factory/waku.nim @@ -91,16 +91,8 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] = logging.setupLog(conf.logLevel, conf.logFormat) - case confCopy.clusterId - - # cluster-id=0 - of 0: - let clusterZeroConf = ClusterConf.ClusterZeroConf() - confCopy.pubsubTopics = clusterZeroConf.pubsubTopics - # TODO: Write some template to "merge" the configs - - # cluster-id=1 (aka The Waku Network) - of 1: + case confCopy.preset + of "default": let twnClusterConf = ClusterConf.TheWakuNetworkConf() if len(confCopy.shards) != 0: confCopy.pubsubTopics = @@ -123,6 +115,7 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] = else: discard + # TODO: check that confCopy.shards are valid against the preset info "Running nwaku node", version = git_version logConfig(confCopy)