feat: switch fleet
This commit is contained in:
parent
5def22d232
commit
ff12bec631
|
@ -173,7 +173,8 @@ var NODE_CONFIG* = %* {
|
|||
"Enabled": false,
|
||||
"Host": "0.0.0.0",
|
||||
"Port": 0,
|
||||
"LightClient": false
|
||||
"LightClient": false,
|
||||
"PersistPeers": true,
|
||||
},
|
||||
"WalletConfig": {
|
||||
"Enabled": true,
|
||||
|
|
|
@ -85,6 +85,24 @@ type
|
|||
DiscoveryLimit*: int
|
||||
Rendezvous*: bool
|
||||
|
||||
Waku2Config = object
|
||||
Enabled*: bool
|
||||
Rendezvous*: bool
|
||||
Host*: string
|
||||
Port*: int
|
||||
KeepAliveInterval*: int
|
||||
LightClient*: bool
|
||||
FullNode*: bool
|
||||
DiscoveryLimit*: int
|
||||
PersistPeers*: bool
|
||||
DataDir*: string
|
||||
MaxMessageSize*: int
|
||||
EnableConfirmations*: bool
|
||||
PeerExchange*: bool
|
||||
EnableDiscV5*: bool
|
||||
UDPPort*: int
|
||||
AutoUpdate*: bool
|
||||
|
||||
ShhextConfig* = object
|
||||
PFSEnabled*: bool
|
||||
BackupDisabledDataDir*: string
|
||||
|
@ -189,7 +207,7 @@ type
|
|||
ClusterConfig*: ClusterConfig
|
||||
LightEthConfig*: LightEthConfig
|
||||
WakuConfig*: WakuConfig
|
||||
WakuV2Config*: WakuConfig
|
||||
WakuV2Config*: Waku2Config
|
||||
BridgeConfig*: BridgeConfig
|
||||
ShhextConfig*: ShhextConfig
|
||||
WalletConfig*: WalletConfig
|
||||
|
@ -296,6 +314,24 @@ proc toDatabaseConfig*(jsonObj: JsonNode): DatabaseConfig =
|
|||
if(jsonObj.getProp("PGConfig", pgConfigObj)):
|
||||
result.PGConfig = toPGConfig(pgConfigObj)
|
||||
|
||||
proc toWaku2Config*(jsonObj: JsonNode): Waku2Config =
|
||||
discard jsonObj.getProp("Enabled", result.Enabled)
|
||||
discard jsonObj.getProp("Rendezvous", result.Rendezvous)
|
||||
discard jsonObj.getProp("Host", result.Host)
|
||||
discard jsonObj.getProp("Port", result.Port)
|
||||
discard jsonObj.getProp("KeepAliveInterval", result.KeepAliveInterval)
|
||||
discard jsonObj.getProp("LightClient", result.LightClient)
|
||||
discard jsonObj.getProp("FullNode", result.FullNode)
|
||||
discard jsonObj.getProp("DiscoveryLimit", result.DiscoveryLimit)
|
||||
discard jsonObj.getProp("PersistPeers", result.PersistPeers)
|
||||
discard jsonObj.getProp("DataDir", result.DataDir)
|
||||
discard jsonObj.getProp("MaxMessageSize", result.MaxMessageSize)
|
||||
discard jsonObj.getProp("EnableConfirmations", result.EnableConfirmations)
|
||||
discard jsonObj.getProp("PeerExchange", result.PeerExchange)
|
||||
discard jsonObj.getProp("EnableDiscV5", result.EnableDiscV5)
|
||||
discard jsonObj.getProp("UDPPort", result.UDPPort)
|
||||
discard jsonObj.getProp("AutoUpdate", result.AutoUpdate)
|
||||
|
||||
proc toWakuConfig*(jsonObj: JsonNode): WakuConfig =
|
||||
discard jsonObj.getProp("Enabled", result.Enabled)
|
||||
discard jsonObj.getProp("LightClient", result.LightClient)
|
||||
|
@ -469,7 +505,7 @@ proc toNodeConfigDto*(jsonObj: JsonNode): NodeConfigDto =
|
|||
|
||||
var wakuV2ConfigObj: JsonNode
|
||||
if(jsonObj.getProp("WakuV2Config", wakuV2ConfigObj)):
|
||||
result.WakuV2Config = toWakuConfig(wakuV2ConfigObj)
|
||||
result.WakuV2Config = toWaku2Config(wakuV2ConfigObj)
|
||||
|
||||
var shhextConfigObj: JsonNode
|
||||
if(jsonObj.getProp("ShhextConfig", shhextConfigObj)):
|
||||
|
|
|
@ -159,7 +159,7 @@ proc setFleet*(self: Service, fleet: string): bool =
|
|||
if(not self.settingsService.saveFleet(fleet)):
|
||||
error "error saving fleet ", procName="setFleet"
|
||||
return false
|
||||
|
||||
|
||||
let fleetType = parseEnum[Fleet](fleet)
|
||||
var newConfiguration = self.configuration
|
||||
newConfiguration.ClusterConfig.Fleet = fleet
|
||||
|
@ -189,7 +189,13 @@ proc setFleet*(self: Service, fleet: string): bool =
|
|||
|
||||
# Disabling go-waku rendezvous
|
||||
# newConfiguration.ClusterConfig.WakuRendezvousNodes = self.fleetConfiguration.getNodes(Fleet.GoWakuTest, FleetNodes.LibP2P)
|
||||
return self.saveConfiguration(newConfiguration)
|
||||
|
||||
try:
|
||||
discard status_node_config.switchFleet(fleet, newConfiguration.toJsonNode())
|
||||
return true
|
||||
except:
|
||||
error "Could not switch fleet"
|
||||
return false
|
||||
|
||||
proc getV2LightMode*(self: Service): bool =
|
||||
return self.configuration.WakuV2Config.LightClient
|
||||
|
|
|
@ -305,11 +305,9 @@ proc saveTelemetryServerUrl*(self: Service, value: string): bool =
|
|||
proc getTelemetryServerUrl*(self: Service): string =
|
||||
return self.settings.telemetryServerUrl
|
||||
|
||||
proc saveFleet*(self: Service, value: string): bool =
|
||||
if(self.saveSetting(KEY_FLEET, value)):
|
||||
self.settings.fleet = value
|
||||
return true
|
||||
return false
|
||||
method saveFleet*(self: Service, value: string): bool =
|
||||
self.settings.fleet = value
|
||||
return true
|
||||
|
||||
proc getFleetAsString*(self: Service): string =
|
||||
if(self.settings.fleet.len == 0):
|
||||
|
|
|
@ -17,3 +17,12 @@ proc getNodeConfig*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
|||
except RpcException as e:
|
||||
error "error doing rpc request", methodName = "getNodeConfig", exception=e.msg
|
||||
raise newException(RpcException, e.msg)
|
||||
|
||||
proc switchFleet*(fleet: string, nodeConfig: JsonNode): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
try:
|
||||
info "switching fleet", fleet
|
||||
let response = status_go.switchFleet(fleet, $nodeConfig)
|
||||
result.result = Json.decode(response, JsonNode)
|
||||
except RpcException as e:
|
||||
error "error doing rpc request", methodName = "saveAccountAndLogin", exception=e.msg
|
||||
raise newException(RpcException, e.msg)
|
|
@ -1 +1 @@
|
|||
Subproject commit a46e18940fbd8dd338f248429d2e3b02dd387cc2
|
||||
Subproject commit 091d500421e87360d0558e1c87c1001db87d3493
|
|
@ -1 +1 @@
|
|||
Subproject commit 8f4c8da9533d1f71359c2e4541b9a47789db209b
|
||||
Subproject commit 16311512cbf66c9eeaf03194707faa19c9390649
|
Loading…
Reference in New Issue