revert cleanup: update ethash to use new metrics interface

This commit is contained in:
Lindsey Gray 2023-12-29 11:44:58 -06:00
parent ff5813f810
commit c01385e088

View file

@ -490,7 +490,7 @@ func New(config Config, notify []string, noverify bool) *Ethash {
caches: newlru(config.CachesInMem, newCache),
datasets: newlru(config.DatasetsInMem, newDataset),
update: make(chan struct{}),
hashrate: metrics.NewMeterForced(),
hashrate: metrics.NewMeter(),
}
if config.PowMode == ModeShared {
ethash.shared = sharedEthash
@ -662,7 +662,7 @@ func (ethash *Ethash) SetThreads(threads int) {
func (ethash *Ethash) Hashrate() float64 {
// Short circuit if we are run the ethash in normal/test mode.
if ethash.config.PowMode != ModeNormal && ethash.config.PowMode != ModeTest {
return ethash.hashrate.Rate1()
return ethash.hashrate.Snapshot().Rate1()
}
var res = make(chan uint64, 1)
@ -670,11 +670,11 @@ func (ethash *Ethash) Hashrate() float64 {
case ethash.remote.fetchRateCh <- res:
case <-ethash.remote.exitCh:
// Return local hashrate only if ethash is stopped.
return ethash.hashrate.Rate1()
return ethash.hashrate.Snapshot().Rate1()
}
// Gather total submitted hash rate of remote sealers.
return ethash.hashrate.Rate1() + float64(<-res)
return ethash.hashrate.Snapshot().Rate1() + float64(<-res)
}
// APIs implements consensus.Engine, returning the user facing RPC APIs.