Skip to content

Commit

Permalink
Merge 23d6a77 into 51391aa
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer authored Sep 13, 2024
2 parents 51391aa + 23d6a77 commit f081254
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
10 changes: 6 additions & 4 deletions apps/wakunode2/wakunode2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions tests/wakunode2/test_app.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
17 changes: 8 additions & 9 deletions waku/factory/waku.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
)
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit f081254

Please sign in to comment.