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