-
Notifications
You must be signed in to change notification settings - Fork 90
feat_: kvstore service integration #17762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import json | ||
|
|
||
| include app_service/common/json_utils | ||
|
|
||
| # kv_store keys: | ||
| const RLN_RATE_LIMIT_ENABLED* = "rlnRateLimitEnabled" | ||
|
|
||
| type | ||
| KvstoreDto* = object | ||
| rlnRateLimitEnabled*: bool | ||
|
|
||
| proc toKvstoreDto*(jsonObj: JsonNode): KvstoreDto = | ||
| discard jsonObj.getProp(RLN_RATE_LIMIT_ENABLED, result.rlnRateLimitEnabled) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import NimQml, chronicles, json, strutils, sequtils, tables | ||
|
|
||
| import app/core/eventemitter | ||
| import backend/kvstore as status_kvstore | ||
|
|
||
| import ./dto | ||
| export dto | ||
|
|
||
| logScope: | ||
| topics = "kvstore-service" | ||
|
|
||
| QtObject: | ||
| type Service* = ref object of QObject | ||
| events: EventEmitter | ||
| kvstore: KvstoreDto | ||
|
|
||
| proc delete*(self: Service) = | ||
| self.QObject.delete | ||
|
|
||
| proc newService*(events: EventEmitter): Service = | ||
| new(result, delete) | ||
| result.events = events | ||
| result.QObject.setup | ||
|
|
||
| proc init*(self: Service) = | ||
| let response = status_kvstore.getStoreEntry() | ||
| self.kvstore = response.result.toKvstoreDto() | ||
|
|
||
| proc isRlnRateLimitEnabled*(self: Service): bool = | ||
| return self.kvstore.rlnRateLimitEnabled | ||
|
|
||
| proc setRlnRateLimitEnabled*(self: Service, value: bool): bool = | ||
| let response = status_kvstore.setRlnRateLimitEnabled(value) | ||
| if (not response.error.isNil): | ||
| error "error set rate limit: ", errDescription = response.error.message | ||
| return false | ||
| self.kvstore.rlnRateLimitEnabled = value | ||
| return true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import json | ||
| import ./core, ./response_type | ||
|
|
||
| export response_type | ||
|
|
||
| proc getStoreEntry*(): RpcResponse[JsonNode] = | ||
| return core.callPrivateRPC("kvstore_getStoreEntry") | ||
|
|
||
| proc setRlnRateLimitEnabled*(value: bool): RpcResponse[JsonNode] = | ||
| let payload = %* [value] | ||
| result = core.callPrivateRPC("kvstore_setRlnRateLimitEnabled", payload) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -481,6 +481,17 @@ SettingsContentBase { | |
| text: qsTr("RPC statistics") | ||
| onClicked: rpcStatsModal.open() | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will this setting do for the user? Adding @jorge-campo in case we need to update the documentation.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be used to enable the RLN rate limit. Here are more detail: status-im/status-go#6475 |
||
| StatusSettingsLineButton { | ||
| anchors.leftMargin: 0 | ||
| anchors.rightMargin: 0 | ||
| text: qsTr("Enable RLN Rate Limit") | ||
| isSwitch: true | ||
| switchChecked: root.advancedStore.isRlnRateLimitEnabled | ||
| onClicked: { | ||
| root.advancedStore.toggleRlnRateLimit() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| FleetsModal { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all proc implementations of
status_kvstorecan throw. I think we could use some exceptions handling.