aboutsummaryrefslogtreecommitdiffstats
path: root/internal/ethapi/api.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-06-11 18:58:17 +0800
committerGitHub <noreply@github.com>2018-06-11 18:58:17 +0800
commit9f7592c802838b5be7b95b3b8b063178813bb3bb (patch)
tree4447ef6273f11e11653beb316b8904c5d9ef0851 /internal/ethapi/api.go
parent1d666cf27ec366a967d9afa0e8a370cb4cf33481 (diff)
parent99483e85b92e07078291442bf1cd4c0db22a262d (diff)
downloaddexon-9f7592c802838b5be7b95b3b8b063178813bb3bb.tar
dexon-9f7592c802838b5be7b95b3b8b063178813bb3bb.tar.gz
dexon-9f7592c802838b5be7b95b3b8b063178813bb3bb.tar.bz2
dexon-9f7592c802838b5be7b95b3b8b063178813bb3bb.tar.lz
dexon-9f7592c802838b5be7b95b3b8b063178813bb3bb.tar.xz
dexon-9f7592c802838b5be7b95b3b8b063178813bb3bb.tar.zst
dexon-9f7592c802838b5be7b95b3b8b063178813bb3bb.zip
Merge pull request #16942 from karalabe/rpc-nil-reply
rpc: support returning nil pointer big.Ints (null)
Diffstat (limited to 'internal/ethapi/api.go')
-rw-r--r--internal/ethapi/api.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 7a736bb76..f95388d65 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -62,8 +62,9 @@ func NewPublicEthereumAPI(b Backend) *PublicEthereumAPI {
}
// GasPrice returns a suggestion for a gas price.
-func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*big.Int, error) {
- return s.b.SuggestPrice(ctx)
+func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) {
+ price, err := s.b.SuggestPrice(ctx)
+ return (*hexutil.Big)(price), err
}
// ProtocolVersion returns the current Ethereum protocol version this node supports
@@ -487,21 +488,20 @@ func NewPublicBlockChainAPI(b Backend) *PublicBlockChainAPI {
}
// BlockNumber returns the block number of the chain head.
-func (s *PublicBlockChainAPI) BlockNumber() *big.Int {
+func (s *PublicBlockChainAPI) BlockNumber() hexutil.Uint64 {
header, _ := s.b.HeaderByNumber(context.Background(), rpc.LatestBlockNumber) // latest header should always be available
- return header.Number
+ return hexutil.Uint64(header.Number.Uint64())
}
// GetBalance returns the amount of wei for the given address in the state of the
// given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta
// block numbers are also allowed.
-func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*big.Int, error) {
+func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*hexutil.Big, error) {
state, _, err := s.b.StateAndHeaderByNumber(ctx, blockNr)
if state == nil || err != nil {
return nil, err
}
- b := state.GetBalance(address)
- return b, state.Error()
+ return (*hexutil.Big)(state.GetBalance(address)), state.Error()
}
// GetBlockByNumber returns the requested block. When blockNr is -1 the chain head is returned. When fullTx is true all