diff options
author | Felix Lange <fjl@twurst.com> | 2016-12-17 22:39:55 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-12-20 21:41:58 +0800 |
commit | cf71f5cd604f4d5c94d9e9b12b121a614d662dc7 (patch) | |
tree | a89491c26dc19fc39bb6d8273eeefa2778ff5ec2 /eth/api.go | |
parent | adab2e16bdf24c2eaf498722187fb36c04a5376b (diff) | |
download | go-tangerine-cf71f5cd604f4d5c94d9e9b12b121a614d662dc7.tar go-tangerine-cf71f5cd604f4d5c94d9e9b12b121a614d662dc7.tar.gz go-tangerine-cf71f5cd604f4d5c94d9e9b12b121a614d662dc7.tar.bz2 go-tangerine-cf71f5cd604f4d5c94d9e9b12b121a614d662dc7.tar.lz go-tangerine-cf71f5cd604f4d5c94d9e9b12b121a614d662dc7.tar.xz go-tangerine-cf71f5cd604f4d5c94d9e9b12b121a614d662dc7.tar.zst go-tangerine-cf71f5cd604f4d5c94d9e9b12b121a614d662dc7.zip |
rpc: remove HexNumber, replace all uses with hexutil types
This change couldn't be automated because HexNumber was used for numbers
of all sizes.
Diffstat (limited to 'eth/api.go')
-rw-r--r-- | eth/api.go | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/eth/api.go b/eth/api.go index 2cc9c843d..6010d149c 100644 --- a/eth/api.go +++ b/eth/api.go @@ -31,6 +31,7 @@ import ( "github.com/ethereum/ethash" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" @@ -69,8 +70,8 @@ func (s *PublicEthereumAPI) Coinbase() (common.Address, error) { } // Hashrate returns the POW hashrate -func (s *PublicEthereumAPI) Hashrate() *rpc.HexNumber { - return rpc.NewHexNumber(s.e.Miner().HashRate()) +func (s *PublicEthereumAPI) Hashrate() hexutil.Uint64 { + return hexutil.Uint64(s.e.Miner().HashRate()) } // PublicMinerAPI provides an API to control the miner. @@ -95,8 +96,8 @@ func (s *PublicMinerAPI) Mining() bool { // SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was // accepted. Note, this is not an indication if the provided work was valid! -func (s *PublicMinerAPI) SubmitWork(nonce rpc.HexNumber, solution, digest common.Hash) bool { - return s.agent.SubmitWork(nonce.Uint64(), digest, solution) +func (s *PublicMinerAPI) SubmitWork(nonce hexutil.Uint64, solution, digest common.Hash) bool { + return s.agent.SubmitWork(uint64(nonce), digest, solution) } // GetWork returns a work package for external miner. The work package consists of 3 strings @@ -119,8 +120,8 @@ func (s *PublicMinerAPI) GetWork() (work [3]string, err error) { // SubmitHashrate can be used for remote miners to submit their hash rate. This enables the node to report the combined // hash rate of all miners which submit work through this node. It accepts the miner hash rate and an identifier which // must be unique between nodes. -func (s *PublicMinerAPI) SubmitHashrate(hashrate rpc.HexNumber, id common.Hash) bool { - s.agent.SubmitHashrate(id, hashrate.Uint64()) +func (s *PublicMinerAPI) SubmitHashrate(hashrate hexutil.Uint64, id common.Hash) bool { + s.agent.SubmitHashrate(id, uint64(hashrate)) return true } @@ -137,18 +138,15 @@ func NewPrivateMinerAPI(e *Ethereum) *PrivateMinerAPI { // Start the miner with the given number of threads. If threads is nil the number of // workers started is equal to the number of logical CPU's that are usable by this process. -func (s *PrivateMinerAPI) Start(threads *rpc.HexNumber) (bool, error) { +func (s *PrivateMinerAPI) Start(threads *hexutil.Uint) (bool, error) { s.e.StartAutoDAG() - + var err error if threads == nil { - threads = rpc.NewHexNumber(runtime.NumCPU()) - } - - err := s.e.StartMining(threads.Int()) - if err == nil { - return true, nil + err = s.e.StartMining(runtime.NumCPU()) + } else { + err = s.e.StartMining(int(*threads)) } - return false, err + return err == nil, err } // Stop the miner @@ -166,8 +164,8 @@ func (s *PrivateMinerAPI) SetExtra(extra string) (bool, error) { } // SetGasPrice sets the minimum accepted gas price for the miner. -func (s *PrivateMinerAPI) SetGasPrice(gasPrice rpc.HexNumber) bool { - s.e.Miner().SetGasPrice(gasPrice.BigInt()) +func (s *PrivateMinerAPI) SetGasPrice(gasPrice hexutil.Big) bool { + s.e.Miner().SetGasPrice((*big.Int)(&gasPrice)) return true } |