mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
consensus, internal: add getHashrate API for ethash
This commit is contained in:
parent
dd83e3d40a
commit
31bcd52d4b
3 changed files with 11 additions and 1 deletions
|
|
@ -97,3 +97,8 @@ func (api *API) SubmitHashRate(rate hexutil.Uint64, id common.Hash) bool {
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetHashrate returns the current hashrate for local CPU miner and remote miner.
|
||||||
|
func (api *API) GetHashrate() uint64 {
|
||||||
|
return uint64(api.ethash.Hashrate())
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errNoMiningWork = errors.New("no mining work available yet, don't panic")
|
errNoMiningWork = errors.New("no mining work available yet")
|
||||||
errInvalidSealResult = errors.New("invalid or stale proof-of-work solution")
|
errInvalidSealResult = errors.New("invalid or stale proof-of-work solution")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,11 @@ web3._extend({
|
||||||
call: 'ethash_getWork',
|
call: 'ethash_getWork',
|
||||||
params: 0
|
params: 0
|
||||||
}),
|
}),
|
||||||
|
new web3._extend.Method({
|
||||||
|
name: 'getHashrate',
|
||||||
|
call: 'ethash_getHashrate',
|
||||||
|
params: 0
|
||||||
|
}),
|
||||||
new web3._extend.Method({
|
new web3._extend.Method({
|
||||||
name: 'submitWork',
|
name: 'submitWork',
|
||||||
call: 'ethash_submitWork',
|
call: 'ethash_submitWork',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue