aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-20 13:53:24 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-20 13:53:24 +0800
commitbde161382a0ce4dad9c422870e16169cfba0fcc0 (patch)
tree32c7b4680c08dc243fa615535a571c4612d5eb80 /rpc
parentb56e20be2760343147f72ca62a8db8bd216903bf (diff)
downloadgo-tangerine-bde161382a0ce4dad9c422870e16169cfba0fcc0.tar.gz
go-tangerine-bde161382a0ce4dad9c422870e16169cfba0fcc0.tar.zst
go-tangerine-bde161382a0ce4dad9c422870e16169cfba0fcc0.zip
inline GetBlockByHash
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go51
1 files changed, 20 insertions, 31 deletions
diff --git a/rpc/api.go b/rpc/api.go
index fccc7f2a4..3efb4c55e 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -97,13 +97,6 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e
return nil
}
-func (p *EthereumApi) GetBlockByHash(blockhash string, includetx bool) (*BlockRes, error) {
- block := p.xeth().EthBlockByHash(blockhash)
- br := NewBlockRes(block)
- br.fullTx = includetx
- return br, nil
-}
-
func (p *EthereumApi) GetBlockByNumber(blocknum int64, includetx bool) (*BlockRes, error) {
block := p.xeth().EthBlockByNumber(blocknum)
br := NewBlockRes(block)
@@ -280,11 +273,11 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
- v, err := p.GetBlockByHash(args.BlockHash, args.IncludeTxs)
- if err != nil {
- return err
- }
- *reply = v
+ block := p.xeth().EthBlockByHash(args.BlockHash)
+ br := NewBlockRes(block)
+ br.fullTx = args.IncludeTxs
+
+ *reply = br
case "eth_getBlockByNumber":
args := new(GetBlockByNumberArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -311,14 +304,14 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
- v, err := p.GetBlockByHash(args.Hash, true)
- if err != nil {
- return err
- }
- if args.Index > int64(len(v.Transactions)) || args.Index < 0 {
+ block := p.xeth().EthBlockByHash(args.Hash)
+ br := NewBlockRes(block)
+ br.fullTx = true
+
+ if args.Index > int64(len(br.Transactions)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}
- *reply = v.Transactions[args.Index]
+ *reply = br.Transactions[args.Index]
case "eth_getTransactionByBlockNumberAndIndex":
args := new(BlockNumIndexArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -339,18 +332,15 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
- v, err := p.GetBlockByHash(args.Hash, false)
- if err != nil {
- return err
- }
- if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
+ br := NewBlockRes(p.xeth().EthBlockByHash(args.Hash))
+
+ if args.Index > int64(len(br.Uncles)) || args.Index < 0 {
return NewValidationError("Index", "does not exist")
}
- uncle, err := p.GetBlockByHash(common.ToHex(v.Uncles[args.Index]), false)
- if err != nil {
- return err
- }
+ uhash := common.ToHex(br.Uncles[args.Index])
+ uncle := NewBlockRes(p.xeth().EthBlockByHash(uhash))
+
*reply = uncle
case "eth_getUncleByBlockNumberAndIndex":
args := new(BlockNumIndexArgs)
@@ -366,10 +356,9 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return NewValidationError("Index", "does not exist")
}
- uncle, err := p.GetBlockByHash(common.ToHex(v.Uncles[args.Index]), false)
- if err != nil {
- return err
- }
+ uhash := common.ToHex(v.Uncles[args.Index])
+ uncle := NewBlockRes(p.xeth().EthBlockByHash(uhash))
+
*reply = uncle
case "eth_getCompilers":
c := []string{""}