From 96cdfb922ea07b2f0fdbe3b20c0b593a29062a45 Mon Sep 17 00:00:00 2001 From: Gabriel mermelstein Date: Mon, 26 Aug 2024 15:07:55 -0600 Subject: [PATCH] chat2 fix and code to temporarily convert from pubsub topics to shards --- apps/chat2/chat2.nim | 6 ++++-- waku/factory/waku.nim | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/chat2/chat2.nim b/apps/chat2/chat2.nim index dd2694cf77..f844deada7 100644 --- a/apps/chat2/chat2.nim +++ b/apps/chat2/chat2.nim @@ -6,7 +6,7 @@ when not (compileOption("threads")): {.push raises: [].} -import std/[strformat, strutils, times, options, random] +import std/[strformat, strutils, times, options, random, sequtils] import confutils, chronicles, @@ -379,7 +379,9 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} = raise newException(ConfigurationError, "rln-relay-cred-path MUST be passed") if conf.relay: - await node.mountRelay(conf.topics.split(" ")) + let shards = + conf.shards.mapIt(RelayShard(clusterId: conf.clusterId, shardId: uint16(it))) + await node.mountRelay(shards) await node.mountLibp2pPing() diff --git a/waku/factory/waku.nim b/waku/factory/waku.nim index ed7047cedb..fbb0daccab 100644 --- a/waku/factory/waku.nim +++ b/waku/factory/waku.nim @@ -103,6 +103,20 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] = logging.setupLog(conf.logLevel, conf.logFormat) + # TODO: remove after pubsubtopic config gets removed + #[ let shards = newSeq[uint16]() + if conf.pubsubTopics.length > 0: + let shardsOpt = topicsToRelayShards(conf.pubsubTopics).valueOr: + error "failed to parse pubsub topic, please format according to static shard specification", + error = $error + return err("failed to parse pubsub topic: " & $error) + + if shardsOpt.isSome(): + let relayShards = shardsOpt.get() + for shard in relayShards: + shards.add(shard.shardId) + confCopy.shards = shards ]# + case confCopy.clusterId # cluster-id=1 (aka The Waku Network)