diff --git a/changelog/muzry_improving_slashing_import.md b/changelog/muzry_improving_slashing_import.md new file mode 100644 index 0000000000..69fcabd6e3 --- /dev/null +++ b/changelog/muzry_improving_slashing_import.md @@ -0,0 +1,2 @@ +### Changed +- Improve readability in slashing import and remove duplicated code diff --git a/cmd/validator/slashing-protection/import.go b/cmd/validator/slashing-protection/import.go index 6c277ca1a2..a180398316 100644 --- a/cmd/validator/slashing-protection/import.go +++ b/cmd/validator/slashing-protection/import.go @@ -61,20 +61,13 @@ func importSlashingProtectionJSON(cliCtx *cli.Context) error { if isDatabaseMinimal { databaseFileDir = filesystem.DatabaseDirName } - return fmt.Errorf("%s (validator database) was not found at path %s, so nothing to export", databaseFileDir, dataDir) - } else { - if !isDatabaseMinimal { - matchPath = filepath.Dir(matchPath) // strip the file name - } - dataDir = matchPath - log.Infof("Found validator database at path %s", dataDir) + return fmt.Errorf("%s (validator database) was not found at path %s, so nothing to import", databaseFileDir, dataDir) } - message := "Found existing database inside of %s" - if !found { - message = "Did not find existing database inside of %s, creating a new one" + if !isDatabaseMinimal { + matchPath = filepath.Dir(matchPath) // strip the file name } - - log.Infof(message, dataDir) + dataDir = matchPath + log.Infof("Found validator database at path %s", dataDir) // Open the validator database. if isDatabaseMinimal {