Skip to content

Commit

Permalink
feat: propose preset option instead of deducing from cluster-id
Browse files Browse the repository at this point in the history
  • Loading branch information
fryorcraken committed Jun 28, 2024
1 parent 55c94b4 commit 3e39a23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
10 changes: 9 additions & 1 deletion waku/factory/external_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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]
Expand Down
13 changes: 3 additions & 10 deletions waku/factory/waku.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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)

Expand Down

0 comments on commit 3e39a23

Please sign in to comment.