aboutsummaryrefslogtreecommitdiffstats
path: root/pow/ethash_algo.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-03-09 22:09:43 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-03-09 22:50:14 +0800
commitf3579f6460ed90a29cca77ffcbcd8047427b686b (patch)
tree692ce9ff832e703e91e4ddf0f4b3c9c3514a8798 /pow/ethash_algo.go
parent5c8fa6ae1a42813e7aec477bd68d98f66f85e0b8 (diff)
downloadgo-tangerine-f3579f6460ed90a29cca77ffcbcd8047427b686b.tar
go-tangerine-f3579f6460ed90a29cca77ffcbcd8047427b686b.tar.gz
go-tangerine-f3579f6460ed90a29cca77ffcbcd8047427b686b.tar.bz2
go-tangerine-f3579f6460ed90a29cca77ffcbcd8047427b686b.tar.lz
go-tangerine-f3579f6460ed90a29cca77ffcbcd8047427b686b.tar.xz
go-tangerine-f3579f6460ed90a29cca77ffcbcd8047427b686b.tar.zst
go-tangerine-f3579f6460ed90a29cca77ffcbcd8047427b686b.zip
pow: make data dumps backwards compatible, fix DAG end
Diffstat (limited to 'pow/ethash_algo.go')
-rw-r--r--pow/ethash_algo.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/pow/ethash_algo.go b/pow/ethash_algo.go
index ace482b93..3737cc5d7 100644
--- a/pow/ethash_algo.go
+++ b/pow/ethash_algo.go
@@ -225,7 +225,8 @@ func generateDataset(dest []uint32, epoch uint64, cache []uint32) {
// Print some debug logs to allow analysis on low end devices
logger := log.New("epoch", epoch)
- defer func(start time.Time) {
+ start := time.Now()
+ defer func() {
elapsed := time.Since(start)
logFn := logger.Debug
@@ -233,7 +234,7 @@ func generateDataset(dest []uint32, epoch uint64, cache []uint32) {
logFn = logger.Info
}
logFn("Generated ethash verification cache", "elapsed", common.PrettyDuration(elapsed))
- }(time.Now())
+ }()
// Figure out whether the bytes need to be swapped for the machine
swapped := !isLittleEndian()
@@ -260,15 +261,15 @@ func generateDataset(dest []uint32, epoch uint64, cache []uint32) {
keccak512 := makeHasher(sha3.NewKeccak512())
// Calculate the data segment this thread should generate
- batch := uint32(size / hashBytes / uint64(threads))
- start := uint32(id) * batch
- limit := start + batch
+ batch := uint32((size + hashBytes*uint64(threads) - 1) / (hashBytes * uint64(threads)))
+ first := uint32(id) * batch
+ limit := first + batch
if limit > uint32(size/hashBytes) {
limit = uint32(size / hashBytes)
}
// Calculate the dataset segment
percent := uint32(size / hashBytes / 100)
- for index := start; index < limit; index++ {
+ for index := first; index < limit; index++ {
item := generateDatasetItem(cache, index, keccak512)
if swapped {
swap(item)
@@ -276,7 +277,7 @@ func generateDataset(dest []uint32, epoch uint64, cache []uint32) {
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))
+ logger.Info("Generating DAG in progress", "percentage", uint64(status*100)/(size/hashBytes), "elapsed", common.PrettyDuration(time.Since(start)))
}
}
}(i)