mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
clear genesis state file when --(force-)clear-db is specified (#15883)
Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
This commit is contained in:
@@ -23,7 +23,7 @@ func Initialize(ctx context.Context, dir string, providers ...Provider) error {
|
||||
setPkgVar(emb, true)
|
||||
return nil
|
||||
}
|
||||
gd, err := findGenesisFile(dir)
|
||||
gd, err := FindStateFile(dir)
|
||||
if err == nil {
|
||||
setPkgVar(gd, true)
|
||||
return nil
|
||||
@@ -65,7 +65,8 @@ func newGenesisData(st state.BeaconState, dir string) (GenesisData, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func findGenesisFile(dir string) (GenesisData, error) {
|
||||
// FindStateFile searches for a valid genesis state file in the specified directory.
|
||||
func FindStateFile(dir string) (GenesisData, error) {
|
||||
if dir == "" {
|
||||
return GenesisData{}, ErrFilePathUnset
|
||||
}
|
||||
|
||||
@@ -100,7 +100,8 @@ type GenesisData struct {
|
||||
initialized bool
|
||||
}
|
||||
|
||||
func (d GenesisData) filePath() string {
|
||||
// FilePath returns the full path to the genesis state file.
|
||||
func (d GenesisData) FilePath() string {
|
||||
parts := [3]string{}
|
||||
parts[genesisPart] = "genesis"
|
||||
parts[timePart] = strconv.FormatInt(d.Time.Unix(), 10)
|
||||
@@ -115,7 +116,7 @@ func persist(d GenesisData) error {
|
||||
if d.FileDir == "" {
|
||||
return ErrFilePathUnset
|
||||
}
|
||||
fpath := d.filePath()
|
||||
fpath := d.FilePath()
|
||||
sb, err := d.State.MarshalSSZ()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "marshal ssz")
|
||||
@@ -144,7 +145,7 @@ func loadState() (state.BeaconState, error) {
|
||||
stateMu.Lock()
|
||||
defer stateMu.Unlock()
|
||||
|
||||
s, err := stateFromFile(data.filePath())
|
||||
s, err := stateFromFile(data.FilePath())
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "InitializeFromProtoUnsafePhase0")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user