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 cp-wjhan committed Oct 10, 2023
1 parent df53219 commit e949d35
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 e949d35

Please sign in to comment.