Skip to content

Commit

Permalink
chore: inject shards info to wakunode
Browse files Browse the repository at this point in the history
  • Loading branch information
darshankabariya committed Jun 12, 2024
1 parent c9692ac commit f14b908
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/wakucanary/wakucanary.nim
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ proc main(rng: ref HmacDrbgContext): Future[int] {.async.} =
error "failed to mount libp2p ping protocol: " & getCurrentExceptionMsg()
return 1

node.mountMetadata(conf.clusterId).isOkOr:
node.mountMetadata(conf.clusterId, conf.shards).isOkOr:
error "failed to mount waku metadata protocol: ", err = error

await node.start()
Expand Down
7 changes: 5 additions & 2 deletions waku/node/waku_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,15 @@ proc connectToNodes*(

## Waku Metadata

proc mountMetadata*(node: WakuNode, clusterId: uint32): Result[void, string] =
proc mountMetadata*(
node: WakuNode, clusterId: uint32, shards: seq[uint16] = @[]
): Result[void, string] =
if not node.wakuMetadata.isNil():
return err("Waku metadata already mounted, skipping")

let metadata = WakuMetadata.new(clusterId, node.enr, node.topicSubscriptionQueue)

for shard in shards:
metadata.shards.incl(uint32(shard))
node.wakuMetadata = metadata
node.peerManager.wakuMetadata = metadata

Expand Down

0 comments on commit f14b908

Please sign in to comment.