mirror of https://github.com/waku-org/nwaku.git
don't start node when it's discv5 only (#2947)
This commit is contained in:
parent
7bd4100595
commit
64855502cf
|
@ -34,7 +34,6 @@ proc setup*(): Waku =
|
|||
# Override configuration
|
||||
conf.maxMessageSize = twnClusterConf.maxMessageSize
|
||||
conf.clusterId = twnClusterConf.clusterId
|
||||
conf.rlnRelay = twnClusterConf.rlnRelay
|
||||
conf.rlnRelayEthContractAddress = twnClusterConf.rlnRelayEthContractAddress
|
||||
conf.rlnRelayDynamic = twnClusterConf.rlnRelayDynamic
|
||||
conf.rlnRelayBandwidthThreshold = twnClusterConf.rlnRelayBandwidthThreshold
|
||||
|
@ -44,6 +43,10 @@ proc setup*(): Waku =
|
|||
conf.rlnEpochSizeSec = twnClusterConf.rlnEpochSizeSec
|
||||
conf.rlnRelayUserMessageLimit = twnClusterConf.rlnRelayUserMessageLimit
|
||||
|
||||
# Only set rlnRelay to true if relay is configured
|
||||
if conf.relay:
|
||||
conf.rlnRelay = twnClusterConf.rlnRelay
|
||||
|
||||
debug "Starting node"
|
||||
var waku = Waku.init(conf).valueOr:
|
||||
error "Waku initialization failed", error = error
|
||||
|
|
|
@ -566,6 +566,12 @@ type WakuNodeConf* = object
|
|||
name: "discv5-bits-per-hop"
|
||||
.}: int
|
||||
|
||||
discv5Only* {.
|
||||
desc: "Disable all protocols other than discv5",
|
||||
defaultValue: false,
|
||||
name: "discv5-only"
|
||||
.}: bool
|
||||
|
||||
## waku peer exchange config
|
||||
peerExchange* {.
|
||||
desc: "Enable waku peer exchange protocol (responder side): true|false",
|
||||
|
|
|
@ -120,6 +120,10 @@ proc setupProtocols(
|
|||
## Optionally include persistent message storage.
|
||||
## No protocols are started yet.
|
||||
|
||||
if conf.discv5Only:
|
||||
notice "Running node only with Discv5, not mounting additional protocols"
|
||||
return ok()
|
||||
|
||||
node.mountMetadata(conf.clusterId).isOkOr:
|
||||
return err("failed to mount waku metadata protocol: " & error)
|
||||
|
||||
|
|
|
@ -105,7 +105,6 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] =
|
|||
# Override configuration
|
||||
confCopy.maxMessageSize = twnClusterConf.maxMessageSize
|
||||
confCopy.clusterId = twnClusterConf.clusterId
|
||||
confCopy.rlnRelay = twnClusterConf.rlnRelay
|
||||
confCopy.rlnRelayEthContractAddress = twnClusterConf.rlnRelayEthContractAddress
|
||||
confCopy.rlnRelayChainId = twnClusterConf.rlnRelayChainId
|
||||
confCopy.rlnRelayDynamic = twnClusterConf.rlnRelayDynamic
|
||||
|
@ -115,6 +114,10 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] =
|
|||
confCopy.discv5BootstrapNodes & twnClusterConf.discv5BootstrapNodes
|
||||
confCopy.rlnEpochSizeSec = twnClusterConf.rlnEpochSizeSec
|
||||
confCopy.rlnRelayUserMessageLimit = twnClusterConf.rlnRelayUserMessageLimit
|
||||
|
||||
# Only set rlnRelay to true if relay is configured
|
||||
if confCopy.relay:
|
||||
confCopy.rlnRelay = twnClusterConf.rlnRelay
|
||||
else:
|
||||
discard
|
||||
|
||||
|
@ -216,15 +219,16 @@ proc updateWaku(waku: ptr Waku): Result[void, string] =
|
|||
return ok()
|
||||
|
||||
proc startWaku*(waku: ptr Waku): Future[Result[void, string]] {.async: (raises: []).} =
|
||||
(await startNode(waku.node, waku.conf, waku.dynamicBootstrapNodes)).isOkOr:
|
||||
return err("error while calling startNode: " & $error)
|
||||
if not waku[].conf.discv5Only:
|
||||
(await startNode(waku.node, waku.conf, waku.dynamicBootstrapNodes)).isOkOr:
|
||||
return err("error while calling startNode: " & $error)
|
||||
|
||||
# Update waku data that is set dynamically on node start
|
||||
updateWaku(waku).isOkOr:
|
||||
return err("Error in updateApp: " & $error)
|
||||
# Update waku data that is set dynamically on node start
|
||||
updateWaku(waku).isOkOr:
|
||||
return err("Error in updateApp: " & $error)
|
||||
|
||||
## Discv5
|
||||
if waku[].conf.discv5Discovery:
|
||||
if waku[].conf.discv5Discovery or waku[].conf.discv5Only:
|
||||
waku[].wakuDiscV5 = waku_discv5.setupDiscoveryV5(
|
||||
waku.node.enr, waku.node.peerManager, waku.node.topicSubscriptionQueue, waku.conf,
|
||||
waku.dynamicBootstrapNodes, waku.rng, waku.key,
|
||||
|
|
Loading…
Reference in New Issue