mirror of https://github.com/waku-org/nwaku.git
fix: setting up node with modified config (#3036)
This commit is contained in:
parent
51391aa2ac
commit
8f28992599
|
@ -58,13 +58,15 @@ when isMainModule:
|
|||
nodeHealthMonitor = WakuNodeHealthMonitor()
|
||||
nodeHealthMonitor.setOverallHealth(HealthStatus.INITIALIZING)
|
||||
|
||||
var confCopy = conf
|
||||
|
||||
let restServer = rest_server_builder.startRestServerEsentials(
|
||||
nodeHealthMonitor, conf
|
||||
nodeHealthMonitor, confCopy
|
||||
).valueOr:
|
||||
error "Starting esential REST server failed.", error = $error
|
||||
quit(QuitFailure)
|
||||
|
||||
var waku = Waku.init(conf).valueOr:
|
||||
var waku = Waku.init(confCopy).valueOr:
|
||||
error "Waku initialization failed", error = error
|
||||
quit(QuitFailure)
|
||||
|
||||
|
@ -77,12 +79,12 @@ when isMainModule:
|
|||
quit(QuitFailure)
|
||||
|
||||
rest_server_builder.startRestServerProtocolSupport(
|
||||
restServer, waku.node, waku.wakuDiscv5, conf
|
||||
restServer, waku.node, waku.wakuDiscv5, confCopy
|
||||
).isOkOr:
|
||||
error "Starting protocols support REST server failed.", error = $error
|
||||
quit(QuitFailure)
|
||||
|
||||
waku.metricsServer = waku_metrics.startMetricsServerAndLogging(conf).valueOr:
|
||||
waku.metricsServer = waku_metrics.startMetricsServerAndLogging(confCopy).valueOr:
|
||||
error "Starting monitoring and external interfaces failed", error = error
|
||||
quit(QuitFailure)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ include waku/factory/waku
|
|||
suite "Wakunode2 - Waku":
|
||||
test "compilation version should be reported":
|
||||
## Given
|
||||
let conf = defaultTestWakuNodeConf()
|
||||
var conf = defaultTestWakuNodeConf()
|
||||
|
||||
let waku = Waku.init(conf).valueOr:
|
||||
raiseAssert error
|
||||
|
@ -43,7 +43,7 @@ suite "Wakunode2 - Waku initialization":
|
|||
|
||||
test "node setup is successful with default configuration":
|
||||
## Given
|
||||
let conf = defaultTestWakuNodeConf()
|
||||
var conf = defaultTestWakuNodeConf()
|
||||
|
||||
## When
|
||||
var waku = Waku.init(conf).valueOr:
|
||||
|
|
|
@ -101,16 +101,15 @@ proc validateShards(conf: WakuNodeConf): Result[void, string] =
|
|||
|
||||
## Initialisation
|
||||
|
||||
proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] =
|
||||
var confCopy = conf
|
||||
proc init*(T: type Waku, confCopy: var WakuNodeConf): Result[Waku, string] =
|
||||
let rng = crypto.newRng()
|
||||
|
||||
logging.setupLog(conf.logLevel, conf.logFormat)
|
||||
logging.setupLog(confCopy.logLevel, confCopy.logFormat)
|
||||
|
||||
# TODO: remove after pubsubtopic config gets removed
|
||||
var shards = newSeq[uint16]()
|
||||
if conf.pubsubTopics.len > 0:
|
||||
let shardsRes = topicsToRelayShards(conf.pubsubTopics)
|
||||
if confCopy.pubsubTopics.len > 0:
|
||||
let shardsRes = topicsToRelayShards(confCopy.pubsubTopics)
|
||||
if shardsRes.isErr():
|
||||
error "failed to parse pubsub topic, please format according to static shard specification",
|
||||
error = shardsRes.error
|
||||
|
@ -120,9 +119,9 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] =
|
|||
|
||||
if shardsOpt.isSome():
|
||||
let relayShards = shardsOpt.get()
|
||||
if relayShards.clusterId != conf.clusterId:
|
||||
if relayShards.clusterId != confCopy.clusterId:
|
||||
error "clusterId of the pubsub topic should match the node's cluster. e.g. --pubsub-topic=/waku/2/rs/22/1 and --cluster-id=22",
|
||||
nodeCluster = conf.clusterId, pubsubCluster = relayShards.clusterId
|
||||
nodeCluster = confCopy.clusterId, pubsubCluster = relayShards.clusterId
|
||||
return err(
|
||||
"clusterId of the pubsub topic should match the node's cluster. e.g. --pubsub-topic=/waku/2/rs/22/1 and --cluster-id=22"
|
||||
)
|
||||
|
@ -191,8 +190,8 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] =
|
|||
let node = nodeRes.get()
|
||||
|
||||
var deliveryMonitor: DeliveryMonitor
|
||||
if conf.reliabilityEnabled:
|
||||
if conf.storenode == "":
|
||||
if confCopy.reliabilityEnabled:
|
||||
if confCopy.storenode == "":
|
||||
return err("A storenode should be set when reliability mode is on")
|
||||
|
||||
let deliveryMonitorRes = DeliveryMonitor.new(
|
||||
|
|
Loading…
Reference in New Issue