Skip to content

Commit

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

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 committed Aug 2, 2022
1 parent c7ce74a commit 6fdc619
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions consensus/ethash/ethash.go
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 6fdc619

Please sign in to comment.