feat: settings cache efficiency update
Current settings caching logic was inefficient when attempting to retrieve settings that contain the sensitive mnemonic. While those calls were limited to the login logic, each call would need to round trip to status-go to get all settings when they wanted to include sensitive data, as the cache was not being updated for these calls. This PR updates the cache regardless if sensitive data is requested of not, effectively making the caching mechanism more efficient during login.
This commit is contained in:
parent
0a108dd849
commit
e47092cfd0
|
@ -35,12 +35,18 @@ proc getSettings*(useCached: bool = true, keepSensitiveData: bool = false): Json
|
|||
if useCached and (not cacheIsDirty) and (not keepSensitiveData):
|
||||
result = settings
|
||||
else:
|
||||
result = callPrivateRPC("settings_getSettings").parseJSON()["result"]
|
||||
var
|
||||
allSettings = callPrivateRPC("settings_getSettings").parseJSON()["result"]
|
||||
var
|
||||
noSensitiveData = allSettings.deepCopy
|
||||
noSensitiveData.delete("mnemonic")
|
||||
if not keepSensitiveData:
|
||||
dirty.store(false)
|
||||
delete(result, "mnemonic")
|
||||
settings = result
|
||||
settingsInited = true
|
||||
result = noSensitiveData
|
||||
else:
|
||||
result = allSettings
|
||||
dirty.store(false)
|
||||
settings = noSensitiveData # never include sensitive data in cache
|
||||
settingsInited = true
|
||||
|
||||
proc getSetting*[T](name: Setting, defaultValue: T, useCached: bool = true): T =
|
||||
let settings: JsonNode = getSettings(useCached, $name == "mnemonic")
|
||||
|
|
Loading…
Reference in New Issue