mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-04 06:53:12 +00:00
fix: setting up node with modified config (#3036)
This commit is contained in:
parent
2a596f4c77
commit
36df0fd838
@ -58,13 +58,15 @@ when isMainModule:
|
|||||||
nodeHealthMonitor = WakuNodeHealthMonitor()
|
nodeHealthMonitor = WakuNodeHealthMonitor()
|
||||||
nodeHealthMonitor.setOverallHealth(HealthStatus.INITIALIZING)
|
nodeHealthMonitor.setOverallHealth(HealthStatus.INITIALIZING)
|
||||||
|
|
||||||
|
var confCopy = conf
|
||||||
|
|
||||||
let restServer = rest_server_builder.startRestServerEsentials(
|
let restServer = rest_server_builder.startRestServerEsentials(
|
||||||
nodeHealthMonitor, conf
|
nodeHealthMonitor, confCopy
|
||||||
).valueOr:
|
).valueOr:
|
||||||
error "Starting esential REST server failed.", error = $error
|
error "Starting esential REST server failed.", error = $error
|
||||||
quit(QuitFailure)
|
quit(QuitFailure)
|
||||||
|
|
||||||
var waku = Waku.init(conf).valueOr:
|
var waku = Waku.init(confCopy).valueOr:
|
||||||
error "Waku initialization failed", error = error
|
error "Waku initialization failed", error = error
|
||||||
quit(QuitFailure)
|
quit(QuitFailure)
|
||||||
|
|
||||||
@ -77,12 +79,12 @@ when isMainModule:
|
|||||||
quit(QuitFailure)
|
quit(QuitFailure)
|
||||||
|
|
||||||
rest_server_builder.startRestServerProtocolSupport(
|
rest_server_builder.startRestServerProtocolSupport(
|
||||||
restServer, waku.node, waku.wakuDiscv5, conf
|
restServer, waku.node, waku.wakuDiscv5, confCopy
|
||||||
).isOkOr:
|
).isOkOr:
|
||||||
error "Starting protocols support REST server failed.", error = $error
|
error "Starting protocols support REST server failed.", error = $error
|
||||||
quit(QuitFailure)
|
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
|
error "Starting monitoring and external interfaces failed", error = error
|
||||||
quit(QuitFailure)
|
quit(QuitFailure)
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ include waku/factory/waku
|
|||||||
suite "Wakunode2 - Waku":
|
suite "Wakunode2 - Waku":
|
||||||
test "compilation version should be reported":
|
test "compilation version should be reported":
|
||||||
## Given
|
## Given
|
||||||
let conf = defaultTestWakuNodeConf()
|
var conf = defaultTestWakuNodeConf()
|
||||||
|
|
||||||
let waku = Waku.init(conf).valueOr:
|
let waku = Waku.init(conf).valueOr:
|
||||||
raiseAssert error
|
raiseAssert error
|
||||||
@ -43,7 +43,7 @@ suite "Wakunode2 - Waku initialization":
|
|||||||
|
|
||||||
test "node setup is successful with default configuration":
|
test "node setup is successful with default configuration":
|
||||||
## Given
|
## Given
|
||||||
let conf = defaultTestWakuNodeConf()
|
var conf = defaultTestWakuNodeConf()
|
||||||
|
|
||||||
## When
|
## When
|
||||||
var waku = Waku.init(conf).valueOr:
|
var waku = Waku.init(conf).valueOr:
|
||||||
|
|||||||
@ -101,16 +101,15 @@ proc validateShards(conf: WakuNodeConf): Result[void, string] =
|
|||||||
|
|
||||||
## Initialisation
|
## Initialisation
|
||||||
|
|
||||||
proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] =
|
proc init*(T: type Waku, confCopy: var WakuNodeConf): Result[Waku, string] =
|
||||||
var confCopy = conf
|
|
||||||
let rng = crypto.newRng()
|
let rng = crypto.newRng()
|
||||||
|
|
||||||
logging.setupLog(conf.logLevel, conf.logFormat)
|
logging.setupLog(confCopy.logLevel, confCopy.logFormat)
|
||||||
|
|
||||||
# TODO: remove after pubsubtopic config gets removed
|
# TODO: remove after pubsubtopic config gets removed
|
||||||
var shards = newSeq[uint16]()
|
var shards = newSeq[uint16]()
|
||||||
if conf.pubsubTopics.len > 0:
|
if confCopy.pubsubTopics.len > 0:
|
||||||
let shardsRes = topicsToRelayShards(conf.pubsubTopics)
|
let shardsRes = topicsToRelayShards(confCopy.pubsubTopics)
|
||||||
if shardsRes.isErr():
|
if shardsRes.isErr():
|
||||||
error "failed to parse pubsub topic, please format according to static shard specification",
|
error "failed to parse pubsub topic, please format according to static shard specification",
|
||||||
error = shardsRes.error
|
error = shardsRes.error
|
||||||
@ -120,9 +119,9 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] =
|
|||||||
|
|
||||||
if shardsOpt.isSome():
|
if shardsOpt.isSome():
|
||||||
let relayShards = shardsOpt.get()
|
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",
|
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(
|
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"
|
"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()
|
let node = nodeRes.get()
|
||||||
|
|
||||||
var deliveryMonitor: DeliveryMonitor
|
var deliveryMonitor: DeliveryMonitor
|
||||||
if conf.reliabilityEnabled:
|
if confCopy.reliabilityEnabled:
|
||||||
if conf.storenode == "":
|
if confCopy.storenode == "":
|
||||||
return err("A storenode should be set when reliability mode is on")
|
return err("A storenode should be set when reliability mode is on")
|
||||||
|
|
||||||
let deliveryMonitorRes = DeliveryMonitor.new(
|
let deliveryMonitorRes = DeliveryMonitor.new(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user