diff --git a/apps/chat2mix/chat2mix.nim b/apps/chat2mix/chat2mix.nim index 3eee046f3..f5306941a 100644 --- a/apps/chat2mix/chat2mix.nim +++ b/apps/chat2mix/chat2mix.nim @@ -425,6 +425,12 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} = var enrBuilder = EnrBuilder.init(nodeKey) + enrBuilder.withWakuRelaySharding( + RelayShards(clusterId: conf.clusterId, shardIds: conf.shards) + ).isOkOr: + error "failed to add sharded topics to ENR", error = error + quit(QuitFailure) + let recordRes = enrBuilder.build() let record = if recordRes.isErr(): @@ -451,11 +457,15 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} = .tryGet() builder.build().tryGet() - await node.start() - #TODO: fix hard-coding. - node.mountSharding(conf.clusterId, 1).isOkOr: + node.mountSharding(conf.clusterId, conf.numShardsInNetwork).isOkOr: error "failed to mount waku sharding: ", error = error quit(QuitFailure) + node.mountMetadata(conf.clusterId).isOkOr: + error "failed to mount waku metadata protocol: ", err = error + quit 1 + + await node.start() + #[ if conf.rlnRelayCredPath == "": raise newException(ConfigurationError, "rln-relay-cred-path MUST be passed") diff --git a/apps/chat2mix/config_chat2mix.nim b/apps/chat2mix/config_chat2mix.nim index 21ee5a641..221cafc3b 100644 --- a/apps/chat2mix/config_chat2mix.nim +++ b/apps/chat2mix/config_chat2mix.nim @@ -91,10 +91,16 @@ type clusterId* {. desc: "Cluster id that the node is running in. Node in a different cluster id is disconnected.", - defaultValue: 42, + defaultValue: 2, name: "cluster-id" .}: uint16 + numShardsInNetwork* {. + desc: "Number of shards in the network", + defaultValue: 1, + name: "num-shards-in-network" + .}: uint32 + shards* {. desc: "Shards index to subscribe to [0..NUM_SHARDS_IN_NETWORK-1]. Argument may be repeated.",