Skip to content

Commit

Permalink
consensus/ethash: remove temp files created during DAG generation (et…
Browse files Browse the repository at this point in the history
…hereum#25381)

This makes it remove not only the actual DAG file, but also the temporary file
which the DAG data is written to while generating.
  • Loading branch information
manoj398 authored and blakehhuynh committed Oct 7, 2022
1 parent 7c8b903 commit 679c151
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions consensus/ethash/ethash.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,11 @@ func (c *cache) generate(dir string, limit int, lock bool, test bool) {
// Iterate over all previous instances and delete old ones
for ep := int(c.epoch) - limit; ep >= 0; ep-- {
seed := seedHash(uint64(ep)*epochLength + 1)
path := filepath.Join(dir, fmt.Sprintf("cache-R%d-%x%s", algorithmRevision, seed[:8], endian))
os.Remove(path)
path := filepath.Join(dir, fmt.Sprintf("cache-R%d-%x%s*", algorithmRevision, seed[:8], endian))
files, _ := filepath.Glob(path) // find also the temp files that are generated.
for _, file := range files {
os.Remove(file)
}
}
})
}
Expand Down

0 comments on commit 679c151

Please sign in to comment.