aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-05-03 14:17:01 +0800
committerGitHub <noreply@github.com>2017-05-03 14:17:01 +0800
commit59966255add632e3ef09799a8b994ec982bd415a (patch)
tree04e73b9e6ebee7bb3b620df9b26611ec07fa4e8b
parent02a29060d2d51c34b7b458c2598ec71cc8f7a584 (diff)
parentf8acc0af7e48ef3e6b1ed710fc429ece81db1dc8 (diff)
downloaddexon-59966255add632e3ef09799a8b994ec982bd415a.tar.gz
dexon-59966255add632e3ef09799a8b994ec982bd415a.tar.zst
dexon-59966255add632e3ef09799a8b994ec982bd415a.zip
Merge pull request #14407 from karalabe/ethash-generation-race
consensus/ethash: fix a timestamp update race
-rw-r--r--consensus/ethash/ethash.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go
index b028f50e6..94a9ea332 100644
--- a/consensus/ethash/ethash.go
+++ b/consensus/ethash/ethash.go
@@ -467,8 +467,9 @@ func (ethash *Ethash) cache(block uint64) []uint32 {
future = &cache{epoch: epoch + 1}
ethash.fcache = future
}
+ // New current cache, set its initial timestamp
+ current.used = time.Now()
}
- current.used = time.Now()
ethash.lock.Unlock()
// Wait for generation finish, bump the timestamp and finalize the cache
@@ -529,8 +530,9 @@ func (ethash *Ethash) dataset(block uint64) []uint32 {
future = &dataset{epoch: epoch + 1}
ethash.fdataset = future
}
+ // New current dataset, set its initial timestamp
+ current.used = time.Now()
}
- current.used = time.Now()
ethash.lock.Unlock()
// Wait for generation finish, bump the timestamp and finalize the cache