feat: wakuV2 light client mode

This commit is contained in:
Richard Ramos 2021-09-06 18:31:10 -04:00 committed by Iuri Matias
parent b783e9a884
commit a5d48a20b3
3 changed files with 92 additions and 1 deletions

View File

@ -38,6 +38,7 @@ QtObject:
stats*: Stats
peerSize: int
bloomBitsSet: int
wakuV2LightClient: bool
proc setup(self: NodeView) =
self.QObject.setup
@ -50,6 +51,7 @@ QtObject:
result.lastMessage = ""
result.wakuBloomFilterMode = false
result.fullNode = false
result.wakuV2LightClient = false
result.setup
proc delete*(self: NodeView) =
@ -124,6 +126,7 @@ QtObject:
let nodeConfig = self.status.settings.getNodeConfig()
self.wakuBloomFilterMode = self.status.settings.getSetting[:bool](Setting.WakuBloomFilterMode)
self.fullNode = nodeConfig["WakuConfig"]["FullNode"].getBool()
self.wakuV2LightClient = nodeConfig["WakuV2Config"]{"LightClient"}.getBool()
self.initialized()
proc wakuVersion*(self: NodeView): int {.slot.} =
@ -202,3 +205,16 @@ QtObject:
notify = peerSizeChanged
proc log*(self: NodeView, logContent: string) {.signal.}
proc getWakuV2LightClient(self: NodeView): bool {.slot.} = self.wakuV2LightClient
QtProperty[bool] WakuV2LightClient:
read = getWakuV2LightClient
notify = initialized
proc setWakuV2LightClient*(self: NodeView, enabled: bool) {.slot.} =
let statusGoResult = self.status.settings.setV2LightMode(enabled)
if statusGoResult.error != "":
error "Error saving updated node config", msg=statusGoResult.error
else:
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported

View File

@ -12,6 +12,7 @@ ScrollView {
width: parent.width
contentHeight: advancedContainer.height + 100
clip: true
property bool isWakuV2: profileModel.fleets.fleet == Constants.waku_prod || profileModel.fleets.fleet === Constants.waku_test
Item {
id: advancedContainer
@ -201,6 +202,7 @@ ScrollView {
}
StatusSectionHeadline {
visible: !isWakuV2
//% "Bloom filter level"
text: qsTrId("bloom-filter-level")
topPadding: Style.current.bigPadding
@ -208,6 +210,7 @@ ScrollView {
}
Row {
visible: !isWakuV2
spacing: 11
Component {
@ -284,6 +287,78 @@ ScrollView {
}
}
StatusSectionHeadline {
visible: isWakuV2
text: qsTr("WakuV2 mode")
topPadding: Style.current.bigPadding
bottomPadding: Style.current.padding
}
Row {
spacing: 11
visible: isWakuV2
Component {
id: wakuV2ModeConfirmationDialogComponent
ConfirmationDialog {
property bool mode: false
id: confirmDialog
//% "Warning!"
title: qsTrId("close-app-title")
//% "The account will be logged out. When you login again, the selected mode will be enabled"
confirmationText: qsTrId("the-account-will-be-logged-out--when-you-login-again--the-selected-mode-will-be-enabled")
onConfirmButtonClicked: {
nodeModel.setWakuV2LightClient(mode)
}
onClosed: {
if(nodeModel.WakuV2LightClient){
btnWakuV2Light.click()
} else {
btnWakuV2Full.click();
}
destroy()
}
}
}
ButtonGroup {
id: wakuV2Group
}
BloomSelectorButton {
id: btnWakuV2Light
buttonGroup: wakuV2Group
checkedByDefault: nodeModel.WakuV2LightClient
//% "Light Node"
btnText: qsTrId("light-node")
onToggled: {
if (!nodeModel.WakuV2LightClient) {
openPopup(wakuV2ModeConfirmationDialogComponent, {light: true})
} else {
btnWakuV2Light.click()
}
}
}
BloomSelectorButton {
id: btnWakuV2Full
buttonGroup: wakuV2Group
checkedByDefault: !nodeModel.WakuV2LightClient
//% "Full Node"
btnText: qsTrId("full-node")
onToggled: {
if (nodeModel.WakuV2LightClient) {
openPopup(wakuV2ModeConfirmationDialogComponent, {light: false})
} else {
btnWakuV2Full.click()
}
}
}
}
StatusSettingsLineButton {
text: qsTr("Download messages")
isSwitch: true

2
vendor/status-lib vendored

@ -1 +1 @@
Subproject commit a80869872d822bdc239cc67f98c6fb3a7f54febe
Subproject commit 8fe7a571bf3600e280a60dc776843236baeea9ff