calcDatasetSize¶
| Source (upstream pre-purge) | Current | |
|---|---|---|
| File | consensus/ethash/algorithm.go |
algorithm.go |
| Symbol | calcDatasetSize |
calcDatasetSize |
| Ref | dde2da0ef~1 |
etc/v1.17.3-full-node |
epoch param kept as int (matching upstream). core-geth changed to uint64 for consistency with calcEpoch, but we prioritize minimal diff. The uint64→int cast happens in datasetSize() caller.
3-way merge — purge → getc ← upstream¶
pre-purge
↗// calcDatasetSize calculates the dataset size for epoch. The dataset size grows linearly,
// however, we always take the highest prime below the linearly growing threshold in order
// to reduce the risk of accidental regularities leading to cyclic behavior.
func calcDatasetSize(epoch int) uint64 {
size := datasetInitBytes + datasetGrowthBytes*uint64(epoch) - mixBytes
for !new(big.Int).SetUint64(size / mixBytes).ProbablyPrime(1) { // Always accurate for n < 2^64
size -= 2 * mixBytes
}
return size
}
core-geth validation — +2 -2
| | | |---|---| | File | [`algorithm.go`](https://github.com/etclabscore/core-geth/blob/v1.12.20/consensus/ethash/algorithm.go) | | Symbol | `calcDatasetSize` | | Ref | `v1.12.20` |--- a/core-geth/consensus/ethash/algorithm.go
+++ b/etc/consensus/ethash/algorithm.go
@@ -1,8 +1,8 @@
// calcDatasetSize calculates the dataset size for epoch. The dataset size grows linearly,
// however, we always take the highest prime below the linearly growing threshold in order
// to reduce the risk of accidental regularities leading to cyclic behavior.
-func calcDatasetSize(epoch uint64) uint64 {
- size := datasetInitBytes + datasetGrowthBytes*epoch - mixBytes
+func calcDatasetSize(epoch int) uint64 {
+ size := datasetInitBytes + datasetGrowthBytes*uint64(epoch) - mixBytes
for !new(big.Int).SetUint64(size / mixBytes).ProbablyPrime(1) { // Always accurate for n < 2^64
size -= 2 * mixBytes
}