Skip to content

all: fix miner hashRate -> hashrate on API calls #22604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion consensus/ethash/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (api *API) SubmitWork(nonce types.BlockNonce, hash, digest common.Hash) boo
//
// It accepts the miner hash rate and an identifier which must be unique
// between nodes.
func (api *API) SubmitHashRate(rate hexutil.Uint64, id common.Hash) bool {
func (api *API) SubmitHashrate(rate hexutil.Uint64, id common.Hash) bool {
if api.ethash.remote == nil {
return false
}
Expand Down
6 changes: 3 additions & 3 deletions consensus/ethash/ethash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestRemoteSealer(t *testing.T) {
}
}

func TestHashRate(t *testing.T) {
func TestHashrate(t *testing.T) {
var (
hashrate = []hexutil.Uint64{100, 200, 300}
expect uint64
Expand All @@ -150,7 +150,7 @@ func TestHashRate(t *testing.T) {

api := &API{ethash}
for i := 0; i < len(hashrate); i += 1 {
if res := api.SubmitHashRate(hashrate[i], ids[i]); !res {
if res := api.SubmitHashrate(hashrate[i], ids[i]); !res {
t.Error("remote miner submit hashrate failed")
}
expect += uint64(hashrate[i])
Expand All @@ -170,7 +170,7 @@ func TestClosedRemoteSealer(t *testing.T) {
t.Error("expect to return an error to indicate ethash is stopped")
}

if res := api.SubmitHashRate(hexutil.Uint64(100), common.HexToHash("a")); res {
if res := api.SubmitHashrate(hexutil.Uint64(100), common.HexToHash("a")); res {
t.Error("expect to return false when submit hashrate to a stopped ethash")
}
}
10 changes: 0 additions & 10 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ func (api *PublicEthereumAPI) Coinbase() (common.Address, error) {
return api.Etherbase()
}

// Hashrate returns the POW hashrate
func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 {
return hexutil.Uint64(api.e.Miner().HashRate())
}

// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
func (api *PublicEthereumAPI) ChainId() (hexutil.Uint64, error) {
// if current block is at or past the EIP-155 replay-protection fork block, return chainID from config
Expand Down Expand Up @@ -149,11 +144,6 @@ func (api *PrivateMinerAPI) SetRecommitInterval(interval int) {
api.e.Miner().SetRecommitInterval(time.Duration(interval) * time.Millisecond)
}

// GetHashrate returns the current hashrate of the miner.
func (api *PrivateMinerAPI) GetHashrate() uint64 {
return api.e.miner.HashRate()
}

// PrivateAdminAPI is the collection of Ethereum full node-related APIs
// exposed over the private admin endpoint.
type PrivateAdminAPI struct {
Expand Down
2 changes: 1 addition & 1 deletion ethstats/ethstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ func (s *Service) reportStats(conn *connWrapper) error {
fullBackend, ok := s.backend.(fullNodeBackend)
if ok {
mining = fullBackend.Miner().Mining()
hashrate = int(fullBackend.Miner().HashRate())
hashrate = int(fullBackend.Miner().Hashrate())

sync := fullBackend.Downloader().Progress()
syncing = fullBackend.CurrentHeader().Number.Uint64() >= sync.HighestBlock
Expand Down
4 changes: 2 additions & 2 deletions internal/web3ext/web3ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ web3._extend({
params: 3,
}),
new web3._extend.Method({
name: 'submitHashRate',
call: 'ethash_submitHashRate',
name: 'submitHashrate',
call: 'ethash_submitHashrate',
params: 2,
}),
]
Expand Down
2 changes: 1 addition & 1 deletion miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (miner *Miner) Mining() bool {
return miner.worker.isRunning()
}

func (miner *Miner) HashRate() uint64 {
func (miner *Miner) Hashrate() uint64 {
if pow, ok := miner.engine.(consensus.PoW); ok {
return uint64(pow.Hashrate())
}
Expand Down