Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulio2002 committed Nov 17, 2024
1 parent ceac528 commit 0df778d
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions cl/phase1/forkchoice/fork_graph/fork_graph_disk_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (f *forkGraphDisk) DumpBeaconStateOnDisk(blockRoot libcommon.Hash, bs *stat
if err != nil {
return
}
version := bs.Version()

go func() {
defer f.stateDumpLock.Unlock()
Expand All @@ -124,7 +125,7 @@ func (f *forkGraphDisk) DumpBeaconStateOnDisk(blockRoot libcommon.Hash, bs *stat
}

// First write the hard fork version
if _, err := f.sszSnappyWriter.Write([]byte{byte(bs.Version())}); err != nil {
if _, err := f.sszSnappyWriter.Write([]byte{byte(version)}); err != nil {
log.Error("failed to write hard fork version", "err", err)
return
}
Expand All @@ -148,22 +149,22 @@ func (f *forkGraphDisk) DumpBeaconStateOnDisk(blockRoot libcommon.Hash, bs *stat
log.Error("failed to sync dumped file", "err", err)
return
}
}()

cacheFile, err := f.fs.OpenFile(getBeaconStateCacheFilename(blockRoot), os.O_TRUNC|os.O_CREATE|os.O_RDWR, 0o755)
if err != nil {
return
}
defer cacheFile.Close()
cacheFile, err := f.fs.OpenFile(getBeaconStateCacheFilename(blockRoot), os.O_TRUNC|os.O_CREATE|os.O_RDWR, 0o755)
if err != nil {
return
}
defer cacheFile.Close()

if err := bs.EncodeCaches(cacheFile); err != nil {
log.Error("failed to encode caches", "err", err)
return
}
if err := bs.EncodeCaches(cacheFile); err != nil {
log.Error("failed to encode caches", "err", err)
return err
}

if err = cacheFile.Sync(); err != nil {
return
}
}()
if err = cacheFile.Sync(); err != nil {
return err
}

return
}

0 comments on commit 0df778d

Please sign in to comment.