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
|
||||
|
||||
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(
|
||||
node: WakuNode, conf: WakuNodeConf, nodeKey: crypto.PrivateKey
|
||||
): Future[Result[void, string]] {.async.} =
|
||||
|
@ -121,9 +127,7 @@ proc setupProtocols(
|
|||
return err("failed to mount waku metadata protocol: " & error)
|
||||
|
||||
# If conf.networkShards is not set, use the number of shards configured as networkShards
|
||||
var networkShards = conf.networkShards
|
||||
if networkShards == uint32(0):
|
||||
networkShards = uint32(conf.shards.len)
|
||||
let networkShards = getNetworkShards(conf)
|
||||
|
||||
node.mountSharding(conf.clusterId, networkShards).isOkOr:
|
||||
return err("failed to mount waku sharding: " & error)
|
||||
|
|
|
@ -87,10 +87,11 @@ func version*(waku: Waku): string =
|
|||
waku.version
|
||||
|
||||
proc validateShards(conf: WakuNodeConf): Result[void, string] =
|
||||
let networkShards = getNetworkShards(conf)
|
||||
|
||||
for shard in conf.shards:
|
||||
if shard >= conf.networkShards:
|
||||
let msg =
|
||||
"Invalid shard: " & $shard & " when networkShards: " & $conf.networkShards
|
||||
if shard >= networkShards:
|
||||
let msg = "Invalid shard: " & $shard & " when networkShards: " & $networkShards
|
||||
# fmt doesn't work
|
||||
error "validateShards failed", error = msg
|
||||
return err(msg)
|
||||
|
|
Loading…
Reference in New Issue