From 41b83fe1cd6d49ee68ab44aa87812d716f0e4399 Mon Sep 17 00:00:00 2001 From: Kobi Gurkan Date: Sun, 12 Apr 2015 15:17:07 +0300 Subject: [PATCH 1/3] adds eth_hashrate RPC method --- eth/backend.go | 1 + rpc/api.go | 2 ++ xeth/xeth.go | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/eth/backend.go b/eth/backend.go index 88456e448..982317314 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -341,6 +341,7 @@ func (s *Ethereum) Etherbase() (eb common.Address, err error) { func (s *Ethereum) StopMining() { s.miner.Stop() } func (s *Ethereum) IsMining() bool { return s.miner.Mining() } +func (s *Ethereum) HashRate() int64 { return s.miner.HashRate() } func (s *Ethereum) Miner() *miner.Miner { return s.miner } // func (s *Ethereum) Logger() logger.LogSystem { return s.logger } diff --git a/rpc/api.go b/rpc/api.go index 66283752b..8a0d759c1 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -62,6 +62,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err *reply = newHexData(api.xeth().Coinbase()) case "eth_mining": *reply = api.xeth().IsMining() + case "eth_hashrate": + *reply = api.xeth().HashRate() case "eth_gasPrice": v := xeth.DefaultGas() *reply = newHexData(v.Bytes()) diff --git a/xeth/xeth.go b/xeth/xeth.go index afcb33e4c..e221f6d20 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -276,6 +276,10 @@ func (self *XEth) IsMining() bool { return self.backend.IsMining() } +func (self *XEth) HashRate() int64 { + return self.backend.HashRate() +} + func (self *XEth) EthVersion() string { return fmt.Sprintf("%d", self.backend.EthVersion()) } From 63c5c7fb2dab6ec931acf2c0c44728bd2068e1a7 Mon Sep 17 00:00:00 2001 From: Kobi Gurkan Date: Sun, 12 Apr 2015 22:04:08 +0300 Subject: [PATCH 2/3] uses newHexNum for eth_hashrate --- rpc/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/api.go b/rpc/api.go index 8a0d759c1..620509cef 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -63,7 +63,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err case "eth_mining": *reply = api.xeth().IsMining() case "eth_hashrate": - *reply = api.xeth().HashRate() + *reply = newHexNum(api.xeth().HashRate()) case "eth_gasPrice": v := xeth.DefaultGas() *reply = newHexData(v.Bytes()) From 9e03c48d438926e177f1ba6e2c51a8068efda57f Mon Sep 17 00:00:00 2001 From: Kobi Gurkan Date: Tue, 21 Apr 2015 16:44:02 +0300 Subject: [PATCH 3/3] move eth_hashrate to ext --- rpc/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 620509cef..f75ad811d 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -62,8 +62,6 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err *reply = newHexData(api.xeth().Coinbase()) case "eth_mining": *reply = api.xeth().IsMining() - case "eth_hashrate": - *reply = newHexNum(api.xeth().HashRate()) case "eth_gasPrice": v := xeth.DefaultGas() *reply = newHexData(v.Bytes()) @@ -463,6 +461,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } *reply = api.xeth().Whisper().Messages(args.Id) + case "ext_hashrate": + *reply = newHexNum(api.xeth().HashRate()) // case "eth_register": // // Placeholder for actual type