mirror of https://github.com/waku-org/nwaku.git
fixed misconfigured network shards
This commit is contained in:
parent
54cc122801
commit
2e3dd360f2
|
@ -110,6 +110,12 @@ proc initNode(
|
||||||
|
|
||||||
## Mount protocols
|
## Mount protocols
|
||||||
|
|
||||||
|
proc getNetworkShards*(conf: WakuNodeConf): uint32 =
|
||||||
|
if conf.networkShards != 0:
|
||||||
|
return conf.networkShards
|
||||||
|
# If conf.networkShards is not set, use the number of shards configured as networkShards
|
||||||
|
return uint32(conf.shards.len)
|
||||||
|
|
||||||
proc setupProtocols(
|
proc setupProtocols(
|
||||||
node: WakuNode, conf: WakuNodeConf, nodeKey: crypto.PrivateKey
|
node: WakuNode, conf: WakuNodeConf, nodeKey: crypto.PrivateKey
|
||||||
): Future[Result[void, string]] {.async.} =
|
): Future[Result[void, string]] {.async.} =
|
||||||
|
@ -121,9 +127,7 @@ proc setupProtocols(
|
||||||
return err("failed to mount waku metadata protocol: " & error)
|
return err("failed to mount waku metadata protocol: " & error)
|
||||||
|
|
||||||
# If conf.networkShards is not set, use the number of shards configured as networkShards
|
# If conf.networkShards is not set, use the number of shards configured as networkShards
|
||||||
var networkShards = conf.networkShards
|
let networkShards = getNetworkShards(conf)
|
||||||
if networkShards == uint32(0):
|
|
||||||
networkShards = uint32(conf.shards.len)
|
|
||||||
|
|
||||||
node.mountSharding(conf.clusterId, networkShards).isOkOr:
|
node.mountSharding(conf.clusterId, networkShards).isOkOr:
|
||||||
return err("failed to mount waku sharding: " & error)
|
return err("failed to mount waku sharding: " & error)
|
||||||
|
|
|
@ -87,10 +87,11 @@ func version*(waku: Waku): string =
|
||||||
waku.version
|
waku.version
|
||||||
|
|
||||||
proc validateShards(conf: WakuNodeConf): Result[void, string] =
|
proc validateShards(conf: WakuNodeConf): Result[void, string] =
|
||||||
|
let networkShards = getNetworkShards(conf)
|
||||||
|
|
||||||
for shard in conf.shards:
|
for shard in conf.shards:
|
||||||
if shard >= conf.networkShards:
|
if shard >= networkShards:
|
||||||
let msg =
|
let msg = "Invalid shard: " & $shard & " when networkShards: " & $networkShards
|
||||||
"Invalid shard: " & $shard & " when networkShards: " & $conf.networkShards
|
|
||||||
# fmt doesn't work
|
# fmt doesn't work
|
||||||
error "validateShards failed", error = msg
|
error "validateShards failed", error = msg
|
||||||
return err(msg)
|
return err(msg)
|
||||||
|
|
Loading…
Reference in New Issue