aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-06-11 18:15:59 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-06-11 18:56:22 +0800
commit99483e85b92e07078291442bf1cd4c0db22a262d (patch)
tree4447ef6273f11e11653beb316b8904c5d9ef0851 /internal
parent1d666cf27ec366a967d9afa0e8a370cb4cf33481 (diff)
downloadgo-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar.gz
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar.bz2
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar.lz
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar.xz
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar.zst
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.zip
rpc: support returning nil pointer big.Ints (null)
Diffstat (limited to 'internal')
-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