mirror of https://github.com/waku-org/nwaku.git
fix: mount metadata in wakucanary (#2793)
* chore: integrate cluster id and shards to waku node.
This commit is contained in:
parent
ab4b5b27bd
commit
3b27aee820
|
@ -18,6 +18,8 @@ The following options are available:
|
|||
-np, --node-port Listening port for waku node [=60000].
|
||||
--websocket-secure-key-path Secure websocket key path: '/path/to/key.txt' .
|
||||
--websocket-secure-cert-path Secure websocket Certificate path: '/path/to/cert.txt' .
|
||||
-c, --cluster-id Cluster ID of the fleet node to check status [Default=1]
|
||||
-s, --shard Shards index to subscribe to topics [ Argument may be repeated ]
|
||||
|
||||
```
|
||||
|
||||
|
|
|
@ -84,6 +84,21 @@ type WakuCanaryConf* = object
|
|||
desc: "Ping the peer node to measure latency", defaultValue: true, name: "ping"
|
||||
.}: bool
|
||||
|
||||
shards* {.
|
||||
desc: "Shards index to subscribe to [0..MAX_SHARDS-1]. Argument may be repeated.",
|
||||
defaultValue: @[],
|
||||
name: "shard",
|
||||
abbr: "s"
|
||||
.}: seq[uint16]
|
||||
|
||||
clusterId* {.
|
||||
desc:
|
||||
"Cluster id that the node is running in. Node in a different cluster id is disconnected.",
|
||||
defaultValue: 1,
|
||||
name: "cluster-id",
|
||||
abbr: "c"
|
||||
.}: uint16
|
||||
|
||||
proc parseCmdArg*(T: type chronos.Duration, p: string): T =
|
||||
try:
|
||||
result = chronos.seconds(parseInt(p))
|
||||
|
@ -190,6 +205,13 @@ proc main(rng: ref HmacDrbgContext): Future[int] {.async.} =
|
|||
|
||||
var enrBuilder = EnrBuilder.init(nodeKey)
|
||||
|
||||
let relayShards = RelayShards.init(conf.clusterId, conf.shards).valueOr:
|
||||
error "Relay shards initialization failed", error = error
|
||||
return 1
|
||||
enrBuilder.withWakuRelaySharding(relayShards).isOkOr:
|
||||
error "Building ENR with relay sharding failed", error = error
|
||||
return 1
|
||||
|
||||
let recordRes = enrBuilder.build()
|
||||
let record =
|
||||
if recordRes.isErr():
|
||||
|
@ -214,6 +236,8 @@ proc main(rng: ref HmacDrbgContext): Future[int] {.async.} =
|
|||
)
|
||||
|
||||
let node = builder.build().tryGet()
|
||||
node.mountMetadata(conf.clusterId).isOkOr:
|
||||
error "failed to mount waku metadata protocol: ", err = error
|
||||
|
||||
if conf.ping:
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue