@@ -135,16 +135,16 @@ proc init*(T: type App, rng: ref HmacDrbgContext, conf: WakuNodeConf): T =
135135 error " failed to parse content topic" , error= res.error
136136 quit (QuitFailure )
137137
138- let pubsubTopicsRes = contentTopicsRes.mapIt (singleHighestWeigthShard (it.get ()))
138+ let shardsRes = contentTopicsRes.mapIt (singleHighestWeigthShard (it.get ()))
139139
140- for res in pubsubTopicsRes :
140+ for res in shardsRes :
141141 if res.isErr ():
142142 error " failed to shard content topic" , error= res.error
143143 quit (QuitFailure )
144144
145- let pubsubTopics = pubsubTopicsRes .mapIt ($ it.get ())
145+ let shards = shardsRes .mapIt ($ it.get ())
146146
147- let topics = pubsubTopics & conf.pubsubTopics
147+ let topics = conf.topics & conf.pubsubTopics & shards
148148
149149 let addShardedTopics = enrBuilder.withShardedTopics (topics)
150150 if addShardedTopics.isErr ():
@@ -360,7 +360,12 @@ proc setupProtocols(node: WakuNode,
360360 peerExchangeHandler = some (handlePeerExchange)
361361
362362 if conf.relay:
363- let pubsubTopics = conf.pubsubTopics
363+ # TODO autoshard content topics only once.
364+ # Already checked for errors in app.init
365+ let contentTopics = conf.contentTopics.mapIt (NsContentTopic .parse (it).expect (" Parsing" ))
366+ let shards = contentTopics.mapIt ($ (singleHighestWeigthShard (it).expect (" Sharding" )))
367+
368+ let pubsubTopics = conf.topics & conf.pubsubTopics & shards
364369 try :
365370 await mountRelay (node, pubsubTopics, peerExchangeHandler = peerExchangeHandler)
366371 except CatchableError :
0 commit comments