mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-10 22:36:24 +00:00
feat: waku bloom filter mode switch
This commit is contained in:
parent
1a9d6d178c
commit
2f2b3726df
@ -31,3 +31,5 @@ proc init*(self: NodeController) =
|
||||
|
||||
self.status.events.on(SignalType.DiscoverySummary.event) do(e:Args):
|
||||
self.status.network.peerSummaryChange(DiscoverySummarySignal(e).enodes)
|
||||
|
||||
self.view.init()
|
||||
|
@ -1,11 +1,15 @@
|
||||
import NimQml
|
||||
import ../../status/[status, node]
|
||||
import NimQml, chronicles, strutils, json
|
||||
import ../../status/[status, node, types, settings, accounts]
|
||||
|
||||
logScope:
|
||||
topics = "node-view"
|
||||
|
||||
QtObject:
|
||||
type NodeView* = ref object of QObject
|
||||
status*: Status
|
||||
callResult: string
|
||||
lastMessage*: string
|
||||
wakuBloomFilterMode*: bool
|
||||
|
||||
proc setup(self: NodeView) =
|
||||
self.QObject.setup
|
||||
@ -15,6 +19,7 @@ QtObject:
|
||||
result.status = status
|
||||
result.callResult = "Use this tool to call JSONRPC methods"
|
||||
result.lastMessage = ""
|
||||
result.wakuBloomFilterMode = false
|
||||
result.setup
|
||||
|
||||
proc delete*(self: NodeView) =
|
||||
@ -58,3 +63,27 @@ QtObject:
|
||||
read = lastMessage
|
||||
write = setLastMessage
|
||||
notify = receivedMessage
|
||||
|
||||
proc initialized(self: NodeView) {.signal.}
|
||||
|
||||
proc getWakuBloomFilterMode*(self: NodeView): bool {.slot.} =
|
||||
result = self.wakuBloomFilterMode
|
||||
|
||||
QtProperty[bool] wakuBloomFilterMode:
|
||||
read = getWakuBloomFilterMode
|
||||
notify = receivedMessage
|
||||
|
||||
proc setWakuBloomFilterMode*(self: NodeView, bloomFilterMode: bool) {.slot.} =
|
||||
discard self.status.settings.saveSetting(Setting.WakuBloomFilterMode, bloomFilterMode)
|
||||
var fleetStr = self.status.settings.getSetting[:string](Setting.Fleet)
|
||||
let fleet = if fleetStr == "": Fleet.PROD else: parseEnum[Fleet](fleetStr)
|
||||
let installationId = self.status.settings.getSetting[:string](Setting.InstallationId)
|
||||
let updatedNodeConfig = self.status.accounts.getNodeConfig(self.status.fleet.config, installationId, $self.status.settings.getCurrentNetwork(), fleet, bloomFilterMode)
|
||||
discard self.status.settings.saveSetting(Setting.NodeConfig, updatedNodeConfig)
|
||||
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
|
||||
|
||||
proc init*(self: NodeView) {.slot.} =
|
||||
self.wakuBloomFilterMode = self.status.settings.getSetting[:bool](Setting.WakuBloomFilterMode)
|
||||
|
||||
|
||||
|
||||
|
@ -146,6 +146,7 @@ proc mainProc() =
|
||||
chat.init()
|
||||
utilsController.init()
|
||||
browserController.init()
|
||||
node.init()
|
||||
|
||||
wallet.checkPendingTransactions()
|
||||
|
||||
@ -175,7 +176,6 @@ proc mainProc() =
|
||||
# Initialize only controllers whose init functions
|
||||
# do not need a running node
|
||||
proc initControllers() =
|
||||
node.init()
|
||||
login.init()
|
||||
onboarding.init()
|
||||
|
||||
|
@ -90,8 +90,8 @@ proc changeNetwork*(self: AccountModel, fleetConfig: FleetConfig, network: strin
|
||||
if statusGoResult.error != "":
|
||||
error "Error removing all recent stickers", msg=statusGoResult.error
|
||||
|
||||
proc getNodeConfig*(self: AccountModel, fleetConfig: FleetConfig, installationId: string, networkConfig: JsonNode, fleet: Fleet = Fleet.PROD): JsonNode =
|
||||
result = status_accounts.getNodeConfig(fleetConfig, installationId, networkConfig, fleet)
|
||||
proc getNodeConfig*(self: AccountModel, fleetConfig: FleetConfig, installationId: string, networkConfig: JsonNode, fleet: Fleet = Fleet.PROD, bloomFilterMode = false): JsonNode =
|
||||
result = status_accounts.getNodeConfig(fleetConfig, installationId, networkConfig, fleet, bloomFilterMode)
|
||||
|
||||
proc getNodeConfig*(self: AccountModel, fleetConfig: FleetConfig, installationId: string, currentNetwork: string = DEFAULT_NETWORK_NAME, fleet: Fleet = Fleet.PROD): JsonNode =
|
||||
result = status_accounts.getNodeConfig(fleetConfig, installationId, currentNetwork, fleet)
|
||||
proc getNodeConfig*(self: AccountModel, fleetConfig: FleetConfig, installationId: string, currentNetwork: string = DEFAULT_NETWORK_NAME, fleet: Fleet = Fleet.PROD, bloomFilterMode = false): JsonNode =
|
||||
result = status_accounts.getNodeConfig(fleetConfig, installationId, currentNetwork, fleet, bloomFilterMode)
|
||||
|
@ -12,7 +12,7 @@ proc getNetworkConfig(currentNetwork: string): JsonNode =
|
||||
result = constants.DEFAULT_NETWORKS.first("id", currentNetwork)
|
||||
|
||||
|
||||
proc getNodeConfig*(fleetConfig: FleetConfig, installationId: string, networkConfig: JsonNode, fleet: Fleet = Fleet.PROD): JsonNode =
|
||||
proc getNodeConfig*(fleetConfig: FleetConfig, installationId: string, networkConfig: JsonNode, fleet: Fleet = Fleet.PROD, bloomFilterMode = false): JsonNode =
|
||||
let upstreamUrl = networkConfig["config"]["UpstreamConfig"]["URL"]
|
||||
var newDataDir = networkConfig["config"]["DataDir"].getStr
|
||||
newDataDir.removeSuffix("_rpc")
|
||||
@ -31,10 +31,11 @@ proc getNodeConfig*(fleetConfig: FleetConfig, installationId: string, networkCon
|
||||
result["ShhextConfig"]["InstallationID"] = newJString(installationId)
|
||||
# TODO: commented since it's not necessary (we do the connections thru C bindings). Enable it thru an option once status-nodes are able to be configured in desktop
|
||||
# result["ListenAddr"] = if existsEnv("STATUS_PORT"): newJString("0.0.0.0:" & $getEnv("STATUS_PORT")) else: newJString("0.0.0.0:30305")
|
||||
result["WakuConfig"]["BloomFilterMode"] = newJBool(bloomFilterMode)
|
||||
|
||||
proc getNodeConfig*(fleetConfig: FleetConfig, installationId: string, currentNetwork: string = constants.DEFAULT_NETWORK_NAME, fleet: Fleet = Fleet.PROD): JsonNode =
|
||||
proc getNodeConfig*(fleetConfig: FleetConfig, installationId: string, currentNetwork: string = constants.DEFAULT_NETWORK_NAME, fleet: Fleet = Fleet.PROD, bloomFilterMode = false): JsonNode =
|
||||
let networkConfig = getNetworkConfig(currentNetwork)
|
||||
result = getNodeConfig(fleetConfig, installationId, networkConfig, fleet)
|
||||
result = getNodeConfig(fleetConfig, installationId, networkConfig, fleet, bloomFilterMode)
|
||||
|
||||
proc hashPassword*(password: string): string =
|
||||
result = "0x" & $keccak_256.digest(password)
|
||||
|
@ -196,6 +196,7 @@ type
|
||||
Fleet = "fleet"
|
||||
VisibleTokens = "wallet/visible-tokens"
|
||||
PinnedMailservers = "pinned-mailservers"
|
||||
WakuBloomFilterMode = "waku-bloom-filter-mode"
|
||||
|
||||
UpstreamConfig* = ref object
|
||||
enabled* {.serializedFieldName("Enabled").}: bool
|
||||
|
@ -132,6 +132,33 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
StatusSettingsLineButton {
|
||||
text: qsTr("Waku Bloom Mode")
|
||||
isSwitch: true
|
||||
switchChecked: nodeModel.wakuBloomFilterMode
|
||||
onClicked: function (checked) {
|
||||
openPopup(bloomConfirmationDialogComponent, {bloomFilterMode: checked})
|
||||
}
|
||||
|
||||
Component {
|
||||
id: bloomConfirmationDialogComponent
|
||||
ConfirmationDialog {
|
||||
property bool bloomFilterMode: false
|
||||
|
||||
id: confirmDialog
|
||||
//% "Warning!"
|
||||
title: qsTrId("close-app-title")
|
||||
confirmationText: qsTrId("The account will be logged out. When you login again, the selected mode will be enabled")
|
||||
onConfirmButtonClicked: {
|
||||
nodeModel.setWakuBloomFilterMode(bloomFilterMode)
|
||||
}
|
||||
onClosed: {
|
||||
destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// StatusSettingsLineButton {
|
||||
// //% "Node Management"
|
||||
// text: qsTrId("node-management")
|
||||
|
Loading…
x
Reference in New Issue
Block a user