Ethash.dataset¶
| Source (upstream pre-purge) | Current | |
|---|---|---|
| File | consensus/ethash/ethash.go |
ethash.go |
| Symbol | Ethash.dataset |
Ethash.dataset |
| Ref | dde2da0ef~1 |
etc/v1.17.3-full-node |
3-way merge — purge → getc ← upstream¶
pre-purgecore-geth
↗// dataset tries to retrieve a mining dataset for the specified block number
// by first checking against a list of in-memory datasets, then against DAGs
// stored on disk, and finally generating one if none can be found.
//
// If async is specified, not only the future but the current DAG is also
// generates on a background thread.
func (ethash *Ethash) dataset(block uint64, async bool) *dataset {
// Retrieve the requested ethash dataset
↗ epochLength := calcEpochLength(block, ethash.config.ECIP1099Block)
epoch := calcEpoch(block, epochLength)
current, future := ethash.datasets.get(epoch, epochLength, ethash.config.ECIP1099Block)
↗ // set async false if ecip-1099 transition in case of regeneratiion bad DAG on disk
if epochLength == epochLengthECIP1099 && (epoch == 42 || epoch == 195) {
async = false
}
↗ // If async is specified, generate everything in a background thread
if async && !current.generated() {
go func() {
current.generate(ethash.config.DatasetDir, ethash.config.DatasetsOnDisk, ethash.config.DatasetsLockMmap, ethash.config.PowMode == ModeTest)
if future != nil {
future.generate(ethash.config.DatasetDir, ethash.config.DatasetsOnDisk, ethash.config.DatasetsLockMmap, ethash.config.PowMode == ModeTest)
}
}()
} else {
// Either blocking generation was requested, or already done
current.generate(ethash.config.DatasetDir, ethash.config.DatasetsOnDisk, ethash.config.DatasetsLockMmap, ethash.config.PowMode == ModeTest)
if future != nil {
go future.generate(ethash.config.DatasetDir, ethash.config.DatasetsOnDisk, ethash.config.DatasetsLockMmap, ethash.config.PowMode == ModeTest)
}
}
return current
}