NagyZoltanPeter 6d35800fce
Chore: api shape phase2 (#3974)
* Move waku.nim from waku/factory to under waku/
* remove unused
* Realize Kernel API in scope of Waku class
* Refactor waku/api into messaging_client, waku/api/types and api_conf into logos_delivery/api
* Make liblogosdelivery and wakunode2 compile, remove waku/api.nim as it was just a import orchestrator
* make test compile and run
* Reconcile master's new send tests to LogosDelivery API after rebase

master commits #3965/#3669-followup added two test cases (Edge lightpush
delivery #3847, store-validation timeout) written against the removed
waku/api.nim createNode helper. Rewrite them to the LogosDelivery shape:
createNode -> LogosDelivery.new, node.node -> node.waku.node,
node.brokerCtx -> node.waku.brokerCtx, node.send -> node.messagingClient.send,
and drop the now-implicit mountMessagingClient calls (LogosDelivery.new
mounts the client internally).
2026-06-25 09:27:01 +02:00

59 lines
1.9 KiB
Nim
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{.push raises: [].}
import tools/confutils/cli_args
import logos_delivery/waku/[common/logging, waku, factory/networks_config]
import
std/[options, strutils, os, sequtils],
chronicles,
chronos,
metrics,
libp2p/crypto/crypto
export
networks_config, waku, logging, options, strutils, os, sequtils, stewNet, chronicles,
chronos, metrics, crypto
proc setup*(): Waku =
const versionString = "version / git commit hash: " & waku.git_version
let rng = crypto.newRng()
let conf = WakuNodeConf.load(version = versionString).valueOr:
error "failure while loading the configuration", error = $error
quit(QuitFailure)
let twnNetworkConf = NetworkPresetConf.TheWakuNetworkConf()
if len(conf.shards) != 0:
conf.pubsubTopics = conf.shards.mapIt(twnNetworkConf.pubsubTopics[it.uint16])
else:
conf.pubsubTopics = twnNetworkConf.pubsubTopics
# Override configuration
conf.maxMessageSize = twnNetworkConf.maxMessageSize
conf.clusterId = some(twnNetworkConf.clusterId)
conf.rlnRelayEthContractAddress = twnNetworkConf.rlnRelayEthContractAddress
conf.rlnRelayDynamic = some(twnNetworkConf.rlnRelayDynamic)
conf.discv5Discovery = some(twnNetworkConf.discv5Discovery)
conf.discv5BootstrapNodes =
conf.discv5BootstrapNodes & twnNetworkConf.discv5BootstrapNodes
conf.rlnEpochSizeSec = some(twnNetworkConf.rlnEpochSizeSec)
conf.rlnRelayUserMessageLimit = some(twnNetworkConf.rlnRelayUserMessageLimit)
# Only set rlnRelay to true if relay is configured
if conf.relay:
conf.rlnRelay = some(twnNetworkConf.rlnRelay)
info "Starting node"
var waku = (waitFor Waku.new(conf)).valueOr:
error "Waku initialization failed", error = error
quit(QuitFailure)
(waitFor waku.start()).isOkOr:
error "Starting waku failed", error = error
quit(QuitFailure)
# set triggerSelf to false, we don't want to process our own stealthCommitments
waku.node.wakuRelay.triggerSelf = false
info "Node setup complete"
return waku