From 55300d4fdbfda751a7a3d4baadd9db65c50b22b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= <peterke@gmail.com>
Date: Wed, 31 Mar 2021 10:56:51 +0300
Subject: [PATCH] all: fix miner hashRate -> hashrate on API calls

---
 consensus/ethash/api.go         |  2 +-
 consensus/ethash/ethash_test.go |  6 +++---
 eth/api.go                      | 10 ----------
 ethstats/ethstats.go            |  2 +-
 internal/web3ext/web3ext.go     |  4 ++--
 miner/miner.go                  |  2 +-
 6 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/consensus/ethash/api.go b/consensus/ethash/api.go
index 68b3a84b0..f4d3802e0 100644
--- a/consensus/ethash/api.go
+++ b/consensus/ethash/api.go
@@ -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
 	}
diff --git a/consensus/ethash/ethash_test.go b/consensus/ethash/ethash_test.go
index eb3850b3b..382eefeec 100644
--- a/consensus/ethash/ethash_test.go
+++ b/consensus/ethash/ethash_test.go
@@ -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
@@ -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])
@@ -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")
 	}
 }
diff --git a/eth/api.go b/eth/api.go
index 53ef91392..c2f72a189 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -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
@@ -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 {
diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go
index 0f386c02f..c7acb9481 100644
--- a/ethstats/ethstats.go
+++ b/ethstats/ethstats.go
@@ -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
diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go
index aba262699..e1f20ad72 100644
--- a/internal/web3ext/web3ext.go
+++ b/internal/web3ext/web3ext.go
@@ -138,8 +138,8 @@ web3._extend({
 			params: 3,
 		}),
 		new web3._extend.Method({
-			name: 'submitHashRate',
-			call: 'ethash_submitHashRate',
+			name: 'submitHashrate',
+			call: 'ethash_submitHashrate',
 			params: 2,
 		}),
 	]
diff --git a/miner/miner.go b/miner/miner.go
index 4d71e307a..00c3d0cb5 100644
--- a/miner/miner.go
+++ b/miner/miner.go
@@ -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())
 	}
-- 
GitLab