Skip to content

Commit

Permalink
Merge pull request #21803 from holiman/ethash
Browse files Browse the repository at this point in the history
consensus/ethash: fix the percentage progress report
  • Loading branch information
karalabe authored Nov 9, 2020
2 parents 7c30f4d + 81ff700 commit 0c34eae
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions consensus/ethash/algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func generateDataset(dest []uint32, epoch uint64, cache []uint32) {
var pend sync.WaitGroup
pend.Add(threads)

var progress uint32
var progress uint64
for i := 0; i < threads; i++ {
go func(id int) {
defer pend.Done()
Expand All @@ -311,16 +311,16 @@ func generateDataset(dest []uint32, epoch uint64, cache []uint32) {
limit = uint32(size / hashBytes)
}
// Calculate the dataset segment
percent := uint32(size / hashBytes / 100)
percent := size / hashBytes / 100
for index := first; index < limit; index++ {
item := generateDatasetItem(cache, index, keccak512)
if swapped {
swap(item)
}
copy(dataset[index*hashBytes:], item)

if status := atomic.AddUint32(&progress, 1); status%percent == 0 {
logger.Info("Generating DAG in progress", "percentage", uint64(status*100)/(size/hashBytes), "elapsed", common.PrettyDuration(time.Since(start)))
if status := atomic.AddUint64(&progress, 1); status%percent == 0 {
logger.Info("Generating DAG in progress", "percentage", (status*100)/(size/hashBytes), "elapsed", common.PrettyDuration(time.Since(start)))
}
}
}(i)
Expand Down

0 comments on commit 0c34eae

Please sign in to comment.