mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-05-12 13:29:42 +00:00
* Add createNode(preset, mode, overrides, additions) nim api * Set p2pTcp/discv5Udp/websocket ports to 0 (auto-bind) in new createNode() * Soft-deprecate --cluster-id=N triggering the associated preset selection * Rewrite applyNetworkConf to apply user-set fields over preset fields * Generate WakuNodeConfOverlay (all Option fields) from WakuNodeConf * New parser for configJson handles new messaging shape and full conf shape * Change all confbuilder defaults from literal values to DefaultXXX consts * Change int/bool WakuNodeConf fields to Option to get user intent w/o sentinels * Make Option CLI default-value help mention defaults now owned by confbuilder * Misc refactors, fixes * Add tests
60 lines
2.0 KiB
Nim
60 lines
2.0 KiB
Nim
{.push raises: [].}
|
||
|
||
import tools/confutils/cli_args
|
||
import waku/[common/logging, factory/[waku, networks_config]]
|
||
import
|
||
std/[options, strutils, os, sequtils],
|
||
chronicles,
|
||
chronos,
|
||
metrics,
|
||
libbacktrace,
|
||
libp2p/crypto/crypto
|
||
|
||
export
|
||
networks_config, waku, logging, options, strutils, os, sequtils, stewNet, chronicles,
|
||
chronos, metrics, libbacktrace, 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 = NetworkConf.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 startWaku(addr waku)).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
|