Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions consensus/ethash/ethash.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func (c *cache) generate(dir string, limit int, test bool) {
size = 1024
}
// If we don't store anything on disk, generate and return.
if dir == "" {
if dir == "" || limit <= 0 {
Copy link
Copy Markdown
Contributor

@CoreyLin CoreyLin Aug 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic of func (c *cache) generate(dir string, limit int, test bool) has already guaranteed that cache is generated before use. This method would firstly load the cache file and memory map it. If the cache file doesn't exist, it would create a new one and memory map it. So it seems that the mechanism here has no problem.

The parameter limit here indicates that how many cache files are allowed to exist on disk. Even if limit <= 0 , it doesn't directly indicate that no cache file exists. At least using limit <= 0 here is not rigorous logically.

Copy link
Copy Markdown
Contributor Author

@de1acr0ix de1acr0ix Aug 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention here is to reuse the limit flag so that there is a way to disable mmap, which is impossible for existing logic. Of course we can introduce a new flag but I believe implicitly disabling mmap when limit is not a positive number is a reasonable choice.

c.cache = make([]uint32, size/4)
generateCache(c.cache, c.epoch, seed)
return
Expand Down Expand Up @@ -305,7 +305,7 @@ func (d *dataset) generate(dir string, limit int, test bool) {
dsize = 32 * 1024
}
// If we don't store anything on disk, generate and return
if dir == "" {
if dir == "" || limit <= 0 {
cache := make([]uint32, csize/4)
generateCache(cache, d.epoch, seed)

Expand Down
2 changes: 1 addition & 1 deletion consensus/ethash/sealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (ethash *Ethash) remote(notify []string, noverify bool) {

start := time.Now()
if !noverify {
if err := ethash.verifySeal(nil, header, true); err != nil {
if err := ethash.verifySeal(nil, header, false); err != nil {
log.Warn("Invalid proof-of-work submitted", "sealhash", sealhash, "elapsed", common.PrettyDuration(time.Since(start)), "err", err)
return false
}
Expand Down