Improve readability in slashing import and remove duplicated code (#15957)

Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
This commit is contained in:
Muzry
2025-11-08 06:12:40 +08:00
committed by GitHub
parent 619334115a
commit 02fb1534e1
2 changed files with 7 additions and 12 deletions

View File

@@ -0,0 +1,2 @@
### Changed
- Improve readability in slashing import and remove duplicated code

View File

@@ -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 {