consensus, internal: add getHashrate API for ethash

This commit is contained in:
rjl493456442 2018-04-26 16:56:33 +08:00
parent dd83e3d40a
commit 31bcd52d4b
3 changed files with 11 additions and 1 deletions

View file

@ -97,3 +97,8 @@ func (api *API) SubmitHashRate(rate hexutil.Uint64, id common.Hash) bool {
return true
}
// GetHashrate returns the current hashrate for local CPU miner and remote miner.
func (api *API) GetHashrate() uint64 {
return uint64(api.ethash.Hashrate())
}

View file

@ -33,7 +33,7 @@ import (
)
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")
)

View file

@ -119,6 +119,11 @@ web3._extend({
call: 'ethash_getWork',
params: 0
}),
new web3._extend.Method({
name: 'getHashrate',
call: 'ethash_getHashrate',
params: 0
}),
new web3._extend.Method({
name: 'submitWork',
call: 'ethash_submitWork',