Skip to content

Commit f8acc0a

Browse files
committed
consensus/ethash: fix a timestamp update race
1 parent 0255ed6 commit f8acc0a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎consensus/ethash/ethash.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,9 @@ func (ethash *Ethash) cache(block uint64) []uint32 {
467467
future = &cache{epoch: epoch + 1}
468468
ethash.fcache = future
469469
}
470+
// New current cache, set its initial timestamp
471+
current.used = time.Now()
470472
}
471-
current.used = time.Now()
472473
ethash.lock.Unlock()
473474

474475
// Wait for generation finish, bump the timestamp and finalize the cache
@@ -529,8 +530,9 @@ func (ethash *Ethash) dataset(block uint64) []uint32 {
529530
future = &dataset{epoch: epoch + 1}
530531
ethash.fdataset = future
531532
}
533+
// New current dataset, set its initial timestamp
534+
current.used = time.Now()
532535
}
533-
current.used = time.Now()
534536
ethash.lock.Unlock()
535537

536538
// Wait for generation finish, bump the timestamp and finalize the cache

0 commit comments

Comments
 (0)