Skip to content

Commit f861c42

Browse files
committed
Don't overwrite chain state on chain init
1 parent c11759e commit f861c42

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

rolling-shutter/cmd/chain/init.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,18 @@ func initFilesWithConfig(tendermintConfig *cfg.Config, config *Config, appState
255255
log.Info().Str("path", nodeKeyFile).Str("id", string(nodeid)).Msg("Generated node key")
256256
}
257257

258-
a := app.NewShutterApp()
259-
a.Gobpath = filepath.Join(tendermintConfig.DBDir(), "shutter.gob")
260-
a.DevMode = config.DevMode
261-
err = a.PersistToDisk()
262-
if err != nil {
263-
return err
258+
gobPath := filepath.Join(tendermintConfig.DBDir(), "shutter.gob")
259+
260+
if tmos.FileExists(gobPath) {
261+
log.Warn().Str("path", gobPath).Msg("Shutter app state file already exists")
262+
} else {
263+
a := app.NewShutterApp()
264+
a.Gobpath = gobPath
265+
a.DevMode = config.DevMode
266+
err = a.PersistToDisk()
267+
if err != nil {
268+
return err
269+
}
264270
}
265271

266272
return nil

0 commit comments

Comments
 (0)