feat: propose `preset` option instead of deducing from cluster-id

This commit is contained in:
fryorcraken 2024-06-28 21:36:00 +10:00
parent 55c94b4b5e
commit 3e39a2343a
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 12 additions and 11 deletions

View File

@ -127,6 +127,12 @@ type WakuNodeConf* = object
.}: seq[ProtectedTopic] .}: seq[ProtectedTopic]
## General node config ## General node config
preset* {.
desc: "Network preset to use." & "Must be one of 'default'",
defaultValue: "default",
name: "preset"
.}: string
clusterId* {. clusterId* {.
desc: desc:
"Cluster id that the node is running in. Node in a different cluster id is disconnected.", "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] .}: seq[string]
shards* {. 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: @[], defaultValue: @[],
name: "shard" name: "shard"
.}: seq[uint16] .}: seq[uint16]

View File

@ -91,16 +91,8 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] =
logging.setupLog(conf.logLevel, conf.logFormat) logging.setupLog(conf.logLevel, conf.logFormat)
case confCopy.clusterId case confCopy.preset
of "default":
# 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:
let twnClusterConf = ClusterConf.TheWakuNetworkConf() let twnClusterConf = ClusterConf.TheWakuNetworkConf()
if len(confCopy.shards) != 0: if len(confCopy.shards) != 0:
confCopy.pubsubTopics = confCopy.pubsubTopics =
@ -123,6 +115,7 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] =
else: else:
discard discard
# TODO: check that confCopy.shards are valid against the preset
info "Running nwaku node", version = git_version info "Running nwaku node", version = git_version
logConfig(confCopy) logConfig(confCopy)