Skip to content

Commit

Permalink
chat2 fix and code to temporarily convert from pubsub topics to shards
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer committed Aug 26, 2024
1 parent a7aeb48 commit 96cdfb9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/chat2/chat2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()

Expand Down
14 changes: 14 additions & 0 deletions waku/factory/waku.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 96cdfb9

Please sign in to comment.