consensus/ethash: improve cache/dataset handling (#15864)
* consensus/ethash: add maxEpoch constant * consensus/ethash: improve cache/dataset handling There are two fixes in this commit: Unmap the memory through a finalizer like the libethash wrapper did. The release logic was incorrect and freed the memory while it was being used, leading to crashes like in #14495 or #14943. Track caches and datasets using simplelru instead of reinventing LRU logic. This should make it easier to see whether it's correct. * consensus/ethash: restore 'future item' logic in lru * consensus/ethash: use mmap even in test mode This makes it possible to shorten the time taken for TestCacheFileEvict. * consensus/ethash: shuffle func calc*Size comments around * consensus/ethash: ensure future cache/dataset is in the lru cache * consensus/ethash: add issue link to the new test * consensus/ethash: fix vet * consensus/ethash: fix test * consensus: tiny issue + nitpick fixes
Showing
- consensus/ethash/algorithm.go 4 additions, 2 deletionsconsensus/ethash/algorithm.go
- consensus/ethash/algorithm_go1.7.go 2 additions, 2 deletionsconsensus/ethash/algorithm_go1.7.go
- consensus/ethash/algorithm_go1.8.go 20 additions, 14 deletionsconsensus/ethash/algorithm_go1.8.go
- consensus/ethash/algorithm_go1.8_test.go 7 additions, 16 deletionsconsensus/ethash/algorithm_go1.8_test.go
- consensus/ethash/consensus.go 7 additions, 3 deletionsconsensus/ethash/consensus.go
- consensus/ethash/ethash.go 119 additions, 169 deletionsconsensus/ethash/ethash.go
- consensus/ethash/ethash_test.go 39 additions, 0 deletionsconsensus/ethash/ethash_test.go
- consensus/ethash/sealer.go 10 additions, 7 deletionsconsensus/ethash/sealer.go
Loading
Please register or sign in to comment