mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
consensus: tiny issue + nitpick fixes
This commit is contained in:
parent
dae4db5831
commit
d948795b90
2 changed files with 7 additions and 1 deletions
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue