aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-04-02 21:13:30 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-04-02 21:13:30 +0800
commit607fc788e378c62ceea72dbc536da0b484323a44 (patch)
tree7960e9677c2d27e481d5eadece80769c9a80bfbd /rpc/api.go
parent1e28b424e7f0f0d16f467ac7bac08b9dc0384106 (diff)
parentb4eef59b6f9631d22fdf62a2b1a40fe05209fccd (diff)
downloaddexon-607fc788e378c62ceea72dbc536da0b484323a44.tar.gz
dexon-607fc788e378c62ceea72dbc536da0b484323a44.tar.zst
dexon-607fc788e378c62ceea72dbc536da0b484323a44.zip
Merge pull request #619 from tgerring/rpcfabian
RPC Fabian fixes
Diffstat (limited to 'rpc/api.go')
-rw-r--r--rpc/api.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 44146c8c7..afd242aa3 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -106,15 +106,15 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
count := api.xethAtStateNum(args.BlockNumber).TxCountAt(args.Address)
*reply = common.ToHex(big.NewInt(int64(count)).Bytes())
case "eth_getBlockTransactionCountByHash":
- args := new(GetBlockByHashArgs)
+ args := new(HashArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
- block := NewBlockRes(api.xeth().EthBlockByHash(args.BlockHash), false)
+ block := NewBlockRes(api.xeth().EthBlockByHash(args.Hash), false)
*reply = common.ToHex(big.NewInt(int64(len(block.Transactions))).Bytes())
case "eth_getBlockTransactionCountByNumber":
- args := new(GetBlockByNumberArgs)
+ args := new(BlockNumArg)
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
@@ -122,16 +122,16 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
block := NewBlockRes(api.xeth().EthBlockByNumber(args.BlockNumber), false)
*reply = common.ToHex(big.NewInt(int64(len(block.Transactions))).Bytes())
case "eth_getUncleCountByBlockHash":
- args := new(GetBlockByHashArgs)
+ args := new(HashArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
- block := api.xeth().EthBlockByHash(args.BlockHash)
+ block := api.xeth().EthBlockByHash(args.Hash)
br := NewBlockRes(block, false)
*reply = common.ToHex(big.NewInt(int64(len(br.Uncles))).Bytes())
case "eth_getUncleCountByBlockNumber":
- args := new(GetBlockByNumberArgs)
+ args := new(BlockNumArg)
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
@@ -144,7 +144,8 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
- *reply = api.xethAtStateNum(args.BlockNumber).CodeAt(args.Address)
+ v := api.xethAtStateNum(args.BlockNumber).CodeAtBytes(args.Address)
+ *reply = newHexData(v)
case "eth_sendTransaction", "eth_transact":
args := new(NewTxArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -177,7 +178,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
}
block := api.xeth().EthBlockByHash(args.BlockHash)
- br := NewBlockRes(block, true)
+ br := NewBlockRes(block, args.IncludeTxs)
*reply = br
case "eth_getBlockByNumber":
@@ -187,7 +188,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
}
block := api.xeth().EthBlockByNumber(args.BlockNumber)
- br := NewBlockRes(block, true)
+ br := NewBlockRes(block, args.IncludeTxs)
*reply = br
case "eth_getTransactionByHash":
@@ -236,6 +237,10 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
}
br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash), false)
+ if br == nil {
+ *reply = nil
+ return nil
+ }
if args.Index >= int64(len(br.Uncles)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
@@ -254,6 +259,11 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
block := api.xeth().EthBlockByNumber(args.BlockNumber)
v := NewBlockRes(block, true)
+ if v == nil {
+ *reply = nil
+ return nil
+ }
+
if args.Index >= int64(len(v.Uncles)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}