consensus: tiny issue + nitpick fixes

This commit is contained in:
Péter Szilágyi 2018-01-23 11:15:40 +02:00
parent dae4db5831
commit d948795b90
No known key found for this signature in database
GPG key ID: E9AE538CEDF8293D
2 changed files with 7 additions and 1 deletions

View file

@ -45,7 +45,7 @@ func calcCacheSize(epoch int) uint64 {
// block number. // block number.
func datasetSize(block uint64) uint64 { func datasetSize(block uint64) uint64 {
epoch := int(block / epochLength) epoch := int(block / epochLength)
if epoch < len(datasetSizes) { if epoch < maxEpoch {
return datasetSizes[epoch] return datasetSizes[epoch]
} }
return calcDatasetSize(epoch) return calcDatasetSize(epoch)

View file

@ -156,6 +156,8 @@ type lru struct {
futureItem interface{} futureItem interface{}
} }
// newlru create a new least-recently-used cache for ither the verification caches
// or the mining datasets.
func newlru(what string, maxItems int, new func(epoch uint64) interface{}) *lru { func newlru(what string, maxItems int, new func(epoch uint64) interface{}) *lru {
if maxItems <= 0 { if maxItems <= 0 {
maxItems = 1 maxItems = 1
@ -203,6 +205,8 @@ type cache struct {
once sync.Once // Ensures the cache is generated only once once sync.Once // Ensures the cache is generated only once
} }
// newCache creates a new ethash verification cache and returns it as a plain Go
// interface to be usable in an LRU cache.
func newCache(epoch uint64) interface{} { func newCache(epoch uint64) interface{} {
return &cache{epoch: epoch} return &cache{epoch: epoch}
} }
@ -277,6 +281,8 @@ type dataset struct {
once sync.Once // Ensures the cache is generated only once once sync.Once // Ensures the cache is generated only once
} }
// newDataset creates a new ethash mining dataset and returns it as a plain Go
// interface to be usable in an LRU cache.
func newDataset(epoch uint64) interface{} { func newDataset(epoch uint64) interface{} {
return &dataset{epoch: epoch} return &dataset{epoch: epoch}
} }