Fix(settings): crash when enabling history archive and disabling logs

fixes #14643
(see more details in the ticket)
This commit is contained in:
Andrey Bocharnikov 2024-05-16 18:03:16 +04:00
parent a776f23965
commit 9d7d3b245e
2 changed files with 21 additions and 7 deletions

View File

@ -72,6 +72,8 @@ proc init*(self: Service) =
return return
proc saveConfiguration(self: Service, configuration: NodeConfigDto): bool = proc saveConfiguration(self: Service, configuration: NodeConfigDto): bool =
# FIXME: this method should be removed and the configuration should be updated in the status-go
# (see SetLogLevel, #14643)
if(not self.settingsService.saveNodeConfiguration(configuration.toJsonNode())): if(not self.settingsService.saveNodeConfiguration(configuration.toJsonNode())):
error "error saving node configuration " error "error saving node configuration "
return false return false
@ -205,14 +207,16 @@ proc isDebugEnabled*(self: Service): bool =
return logLevel in DEBUG_LOG_LEVELS return logLevel in DEBUG_LOG_LEVELS
proc setLogLevel*(self: Service, logLevel: LogLevel): bool = proc setLogLevel*(self: Service, logLevel: LogLevel): bool =
var newConfiguration = self.configuration let response = status_node_config.setLogLevel(logLevel)
newConfiguration.LogLevel = $logLevel
if self.saveConfiguration(newConfiguration): if not response.error.isNil:
self.events.emit(SIGNAL_NODE_LOG_LEVEL_UPDATE, NodeLogLevelUpdatedArgs(logLevel: logLevel)) error "failed to set log level: ", errDescription = response.error.message
return true
else:
return false return false
self.configuration.LogLevel = $logLevel
self.events.emit(SIGNAL_NODE_LOG_LEVEL_UPDATE, NodeLogLevelUpdatedArgs(logLevel: logLevel))
return true
proc getNimbusProxyConfig(self: Service): bool = proc getNimbusProxyConfig(self: Service): bool =
return self.configuration.NimbusProxyConfig.Enabled return self.configuration.NimbusProxyConfig.Enabled

View File

@ -40,4 +40,14 @@ proc disableCommunityHistoryArchiveSupport*(): RpcResponse[JsonNode] =
result = core.callPrivateRPC("disableCommunityHistoryArchiveProtocol".prefix) result = core.callPrivateRPC("disableCommunityHistoryArchiveProtocol".prefix)
except RpcException as e: except RpcException as e:
error "error doing rpc request", methodName = "disableCommunityHistoryArchiveProtocol", exception=e.msg error "error doing rpc request", methodName = "disableCommunityHistoryArchiveProtocol", exception=e.msg
raise newException(RpcException, e.msg) raise newException(RpcException, e.msg)
proc setLogLevel*(logLevel: LogLevel): RpcResponse[JsonNode] =
try:
let payload = %*[{
"logLevel": $logLevel
}]
result = core.callPrivateRPC("setLogLevel".prefix, payload)
except RpcException as e:
error "error doing rpc request", methodName = "setLogLevel", exception=e.msg
raise newException(RpcException, e.msg)