feat: switch fleet

This commit is contained in:
Richard Ramos 2022-03-17 15:47:18 -04:00
parent 5def22d232
commit ff12bec631
7 changed files with 62 additions and 12 deletions

View File

@ -173,7 +173,8 @@ var NODE_CONFIG* = %* {
"Enabled": false, "Enabled": false,
"Host": "0.0.0.0", "Host": "0.0.0.0",
"Port": 0, "Port": 0,
"LightClient": false "LightClient": false,
"PersistPeers": true,
}, },
"WalletConfig": { "WalletConfig": {
"Enabled": true, "Enabled": true,

View File

@ -85,6 +85,24 @@ type
DiscoveryLimit*: int DiscoveryLimit*: int
Rendezvous*: bool 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 ShhextConfig* = object
PFSEnabled*: bool PFSEnabled*: bool
BackupDisabledDataDir*: string BackupDisabledDataDir*: string
@ -189,7 +207,7 @@ type
ClusterConfig*: ClusterConfig ClusterConfig*: ClusterConfig
LightEthConfig*: LightEthConfig LightEthConfig*: LightEthConfig
WakuConfig*: WakuConfig WakuConfig*: WakuConfig
WakuV2Config*: WakuConfig WakuV2Config*: Waku2Config
BridgeConfig*: BridgeConfig BridgeConfig*: BridgeConfig
ShhextConfig*: ShhextConfig ShhextConfig*: ShhextConfig
WalletConfig*: WalletConfig WalletConfig*: WalletConfig
@ -296,6 +314,24 @@ proc toDatabaseConfig*(jsonObj: JsonNode): DatabaseConfig =
if(jsonObj.getProp("PGConfig", pgConfigObj)): if(jsonObj.getProp("PGConfig", pgConfigObj)):
result.PGConfig = toPGConfig(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 = proc toWakuConfig*(jsonObj: JsonNode): WakuConfig =
discard jsonObj.getProp("Enabled", result.Enabled) discard jsonObj.getProp("Enabled", result.Enabled)
discard jsonObj.getProp("LightClient", result.LightClient) discard jsonObj.getProp("LightClient", result.LightClient)
@ -469,7 +505,7 @@ proc toNodeConfigDto*(jsonObj: JsonNode): NodeConfigDto =
var wakuV2ConfigObj: JsonNode var wakuV2ConfigObj: JsonNode
if(jsonObj.getProp("WakuV2Config", wakuV2ConfigObj)): if(jsonObj.getProp("WakuV2Config", wakuV2ConfigObj)):
result.WakuV2Config = toWakuConfig(wakuV2ConfigObj) result.WakuV2Config = toWaku2Config(wakuV2ConfigObj)
var shhextConfigObj: JsonNode var shhextConfigObj: JsonNode
if(jsonObj.getProp("ShhextConfig", shhextConfigObj)): if(jsonObj.getProp("ShhextConfig", shhextConfigObj)):

View File

@ -159,7 +159,7 @@ proc setFleet*(self: Service, fleet: string): bool =
if(not self.settingsService.saveFleet(fleet)): if(not self.settingsService.saveFleet(fleet)):
error "error saving fleet ", procName="setFleet" error "error saving fleet ", procName="setFleet"
return false return false
let fleetType = parseEnum[Fleet](fleet) let fleetType = parseEnum[Fleet](fleet)
var newConfiguration = self.configuration var newConfiguration = self.configuration
newConfiguration.ClusterConfig.Fleet = fleet newConfiguration.ClusterConfig.Fleet = fleet
@ -189,7 +189,13 @@ proc setFleet*(self: Service, fleet: string): bool =
# Disabling go-waku rendezvous # Disabling go-waku rendezvous
# newConfiguration.ClusterConfig.WakuRendezvousNodes = self.fleetConfiguration.getNodes(Fleet.GoWakuTest, FleetNodes.LibP2P) # 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 = proc getV2LightMode*(self: Service): bool =
return self.configuration.WakuV2Config.LightClient return self.configuration.WakuV2Config.LightClient

View File

@ -305,11 +305,9 @@ proc saveTelemetryServerUrl*(self: Service, value: string): bool =
proc getTelemetryServerUrl*(self: Service): string = proc getTelemetryServerUrl*(self: Service): string =
return self.settings.telemetryServerUrl return self.settings.telemetryServerUrl
proc saveFleet*(self: Service, value: string): bool = method saveFleet*(self: Service, value: string): bool =
if(self.saveSetting(KEY_FLEET, value)): self.settings.fleet = value
self.settings.fleet = value return true
return true
return false
proc getFleetAsString*(self: Service): string = proc getFleetAsString*(self: Service): string =
if(self.settings.fleet.len == 0): if(self.settings.fleet.len == 0):

View File

@ -17,3 +17,12 @@ proc getNodeConfig*(): RpcResponse[JsonNode] {.raises: [Exception].} =
except RpcException as e: except RpcException as e:
error "error doing rpc request", methodName = "getNodeConfig", exception=e.msg error "error doing rpc request", methodName = "getNodeConfig", exception=e.msg
raise newException(RpcException, 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

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 8f4c8da9533d1f71359c2e4541b9a47789db209b Subproject commit 16311512cbf66c9eeaf03194707faa19c9390649