Skip to content

Commit d990df9

Browse files
slavikusshrikus
andauthored
consensus/ethash: use 64bit indexes for the DAG generation (#21793)
* Bit boundary fix for the DAG generation routine * Fix unnecessary conversion warnings Co-authored-by: Sergey Pavlov <[email protected]>
1 parent 27d93c1 commit d990df9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

consensus/ethash/algorithm.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,16 @@ func generateDataset(dest []uint32, epoch uint64, cache []uint32) {
304304
keccak512 := makeHasher(sha3.NewLegacyKeccak512())
305305

306306
// Calculate the data segment this thread should generate
307-
batch := uint32((size + hashBytes*uint64(threads) - 1) / (hashBytes * uint64(threads)))
308-
first := uint32(id) * batch
307+
batch := (size + hashBytes*uint64(threads) - 1) / (hashBytes * uint64(threads))
308+
first := uint64(id) * batch
309309
limit := first + batch
310-
if limit > uint32(size/hashBytes) {
311-
limit = uint32(size / hashBytes)
310+
if limit > size/hashBytes {
311+
limit = size / hashBytes
312312
}
313313
// Calculate the dataset segment
314314
percent := size / hashBytes / 100
315315
for index := first; index < limit; index++ {
316-
item := generateDatasetItem(cache, index, keccak512)
316+
item := generateDatasetItem(cache, uint32(index), keccak512)
317317
if swapped {
318318
swap(item)
319319
}

0 commit comments

Comments
 (0)