From d21b89ccc626f47d6822a7ac936c6a9bbc491585 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Sun, 27 Feb 2022 11:23:07 -0400 Subject: [PATCH] fix: code climate warnings --- api/geth_backend.go | 50 +++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/api/geth_backend.go b/api/geth_backend.go index e95b09348..c001e18c7 100644 --- a/api/geth_backend.go +++ b/api/geth_backend.go @@ -271,20 +271,7 @@ func (b *GethStatusBackend) ensureAppDBOpened(account multiaccounts.Account, pas return nil } -// StartNodeWithKey instead of loading addresses from database this method derives address from key -// and uses it in application. -// TODO: we should use a proper struct with optional values instead of duplicating the regular functions -// with small variants for keycard, this created too many bugs -func (b *GethStatusBackend) startNodeWithKey(acc multiaccounts.Account, password string, keyHex string) error { - err := b.ensureAppDBOpened(acc, password) - if err != nil { - return err - } - - if b.loadNodeConfig(nil) != nil { - return err - } - +func (b *GethStatusBackend) setupLogSettings() error { logSettings := logutils.LogSettings{ Enabled: b.config.LogEnabled, MobileSystem: b.config.LogMobileSystem, @@ -297,6 +284,28 @@ func (b *GethStatusBackend) startNodeWithKey(acc multiaccounts.Account, password if err := logutils.OverrideRootLogWithConfig(logSettings, false); err != nil { return err } + return nil +} + +// StartNodeWithKey instead of loading addresses from database this method derives address from key +// and uses it in application. +// TODO: we should use a proper struct with optional values instead of duplicating the regular functions +// with small variants for keycard, this created too many bugs +func (b *GethStatusBackend) startNodeWithKey(acc multiaccounts.Account, password string, keyHex string) error { + err := b.ensureAppDBOpened(acc, password) + if err != nil { + return err + } + + err = b.loadNodeConfig(nil) + if err != nil { + return err + } + + err = b.setupLogSettings() + if err != nil { + return err + } b.account = &acc accountsDB, err := accounts.NewDB(b.appDB) @@ -372,18 +381,11 @@ func (b *GethStatusBackend) startNodeWithAccount(acc multiaccounts.Account, pass return err } - logSettings := logutils.LogSettings{ - Enabled: b.config.LogEnabled, - MobileSystem: b.config.LogMobileSystem, - Level: b.config.LogLevel, - File: b.config.LogFile, - MaxSize: b.config.LogMaxSize, - MaxBackups: b.config.LogMaxBackups, - CompressRotated: b.config.LogCompressRotated, - } - if err := logutils.OverrideRootLogWithConfig(logSettings, false); err != nil { + err = b.setupLogSettings() + if err != nil { return err } + b.account = &acc accountsDB, err := accounts.NewDB(b.appDB) if err != nil {