@@ -163,7 +163,7 @@ func generateCache(dest []uint32, epoch uint64, seed []byte) {
163
163
rows := int (size ) / hashBytes
164
164
165
165
// Start a monitoring goroutine to report progress on low end devices
166
- var progress uint32
166
+ var progress atomic. Uint32
167
167
168
168
done := make (chan struct {})
169
169
defer close (done )
@@ -174,7 +174,7 @@ func generateCache(dest []uint32, epoch uint64, seed []byte) {
174
174
case <- done :
175
175
return
176
176
case <- time .After (3 * time .Second ):
177
- logger .Info ("Generating ethash verification cache" , "percentage" , atomic . LoadUint32 ( & progress )* 100 / uint32 (rows )/ (cacheRounds + 1 ), "elapsed" , common .PrettyDuration (time .Since (start )))
177
+ logger .Info ("Generating ethash verification cache" , "percentage" , progress . Load ( )* 100 / uint32 (rows )/ (cacheRounds + 1 ), "elapsed" , common .PrettyDuration (time .Since (start )))
178
178
}
179
179
}
180
180
}()
@@ -185,7 +185,7 @@ func generateCache(dest []uint32, epoch uint64, seed []byte) {
185
185
keccak512 (cache , seed )
186
186
for offset := uint64 (hashBytes ); offset < size ; offset += hashBytes {
187
187
keccak512 (cache [offset :], cache [offset - hashBytes :offset ])
188
- atomic . AddUint32 ( & progress , 1 )
188
+ progress . Add ( 1 )
189
189
}
190
190
// Use a low-round version of randmemohash
191
191
temp := make ([]byte , hashBytes )
@@ -200,7 +200,7 @@ func generateCache(dest []uint32, epoch uint64, seed []byte) {
200
200
bitutil .XORBytes (temp , cache [srcOff :srcOff + hashBytes ], cache [xorOff :xorOff + hashBytes ])
201
201
keccak512 (cache [dstOff :], temp )
202
202
203
- atomic . AddUint32 ( & progress , 1 )
203
+ progress . Add ( 1 )
204
204
}
205
205
}
206
206
// Swap the byte order on big endian systems and return
@@ -299,7 +299,7 @@ func generateDataset(dest []uint32, epoch uint64, cache []uint32) {
299
299
var pend sync.WaitGroup
300
300
pend .Add (threads )
301
301
302
- var progress uint64
302
+ var progress atomic. Uint64
303
303
for i := 0 ; i < threads ; i ++ {
304
304
go func (id int ) {
305
305
defer pend .Done ()
@@ -323,7 +323,7 @@ func generateDataset(dest []uint32, epoch uint64, cache []uint32) {
323
323
}
324
324
copy (dataset [index * hashBytes :], item )
325
325
326
- if status := atomic . AddUint64 ( & progress , 1 ); status % percent == 0 {
326
+ if status := progress . Add ( 1 ); status % percent == 0 {
327
327
logger .Info ("Generating DAG in progress" , "percentage" , (status * 100 )/ (size / hashBytes ), "elapsed" , common .PrettyDuration (time .Since (start )))
328
328
}
329
329
}
0 commit comments