mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
revert cleanup: update ethash to use new metrics interface
This commit is contained in:
parent
ff5813f810
commit
c01385e088
1 changed files with 4 additions and 4 deletions
|
|
@ -490,7 +490,7 @@ func New(config Config, notify []string, noverify bool) *Ethash {
|
||||||
caches: newlru(config.CachesInMem, newCache),
|
caches: newlru(config.CachesInMem, newCache),
|
||||||
datasets: newlru(config.DatasetsInMem, newDataset),
|
datasets: newlru(config.DatasetsInMem, newDataset),
|
||||||
update: make(chan struct{}),
|
update: make(chan struct{}),
|
||||||
hashrate: metrics.NewMeterForced(),
|
hashrate: metrics.NewMeter(),
|
||||||
}
|
}
|
||||||
if config.PowMode == ModeShared {
|
if config.PowMode == ModeShared {
|
||||||
ethash.shared = sharedEthash
|
ethash.shared = sharedEthash
|
||||||
|
|
@ -662,7 +662,7 @@ func (ethash *Ethash) SetThreads(threads int) {
|
||||||
func (ethash *Ethash) Hashrate() float64 {
|
func (ethash *Ethash) Hashrate() float64 {
|
||||||
// Short circuit if we are run the ethash in normal/test mode.
|
// Short circuit if we are run the ethash in normal/test mode.
|
||||||
if ethash.config.PowMode != ModeNormal && ethash.config.PowMode != ModeTest {
|
if ethash.config.PowMode != ModeNormal && ethash.config.PowMode != ModeTest {
|
||||||
return ethash.hashrate.Rate1()
|
return ethash.hashrate.Snapshot().Rate1()
|
||||||
}
|
}
|
||||||
var res = make(chan uint64, 1)
|
var res = make(chan uint64, 1)
|
||||||
|
|
||||||
|
|
@ -670,11 +670,11 @@ func (ethash *Ethash) Hashrate() float64 {
|
||||||
case ethash.remote.fetchRateCh <- res:
|
case ethash.remote.fetchRateCh <- res:
|
||||||
case <-ethash.remote.exitCh:
|
case <-ethash.remote.exitCh:
|
||||||
// Return local hashrate only if ethash is stopped.
|
// 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.
|
// 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.
|
// APIs implements consensus.Engine, returning the user facing RPC APIs.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue