Skip to content

Commit a378ca8

Browse files
manoj398blakehhuynh
authored andcommitted
consensus/ethash: remove temp files created during DAG generation (ethereum#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.
1 parent b27fdd6 commit a378ca8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

consensus/ethash/ethash.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,11 @@ func (c *cache) generate(dir string, limit int, lock bool, test bool) {
278278
// Iterate over all previous instances and delete old ones
279279
for ep := int(c.epoch) - limit; ep >= 0; ep-- {
280280
seed := seedHash(uint64(ep)*epochLength + 1)
281-
path := filepath.Join(dir, fmt.Sprintf("cache-R%d-%x%s", algorithmRevision, seed[:8], endian))
282-
os.Remove(path)
281+
path := filepath.Join(dir, fmt.Sprintf("cache-R%d-%x%s*", algorithmRevision, seed[:8], endian))
282+
files, _ := filepath.Glob(path) // find also the temp files that are generated.
283+
for _, file := range files {
284+
os.Remove(file)
285+
}
283286
}
284287
})
285288
}

0 commit comments

Comments
 (0)