inline GetBlockByHash
This commit is contained in:
parent
b56e20be27
commit
bde161382a
51
rpc/api.go
51
rpc/api.go
@ -97,13 +97,6 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageAtArgs, reply *interface{}) e
|
|||||||
return nil
|
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) {
|
func (p *EthereumApi) GetBlockByNumber(blocknum int64, includetx bool) (*BlockRes, error) {
|
||||||
block := p.xeth().EthBlockByNumber(blocknum)
|
block := p.xeth().EthBlockByNumber(blocknum)
|
||||||
br := NewBlockRes(block)
|
br := NewBlockRes(block)
|
||||||
@ -280,11 +273,11 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := p.GetBlockByHash(args.BlockHash, args.IncludeTxs)
|
block := p.xeth().EthBlockByHash(args.BlockHash)
|
||||||
if err != nil {
|
br := NewBlockRes(block)
|
||||||
return err
|
br.fullTx = args.IncludeTxs
|
||||||
}
|
|
||||||
*reply = v
|
*reply = br
|
||||||
case "eth_getBlockByNumber":
|
case "eth_getBlockByNumber":
|
||||||
args := new(GetBlockByNumberArgs)
|
args := new(GetBlockByNumberArgs)
|
||||||
if err := json.Unmarshal(req.Params, &args); err != nil {
|
if err := json.Unmarshal(req.Params, &args); err != nil {
|
||||||
@ -311,14 +304,14 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := p.GetBlockByHash(args.Hash, true)
|
block := p.xeth().EthBlockByHash(args.Hash)
|
||||||
if err != nil {
|
br := NewBlockRes(block)
|
||||||
return err
|
br.fullTx = true
|
||||||
}
|
|
||||||
if args.Index > int64(len(v.Transactions)) || args.Index < 0 {
|
if args.Index > int64(len(br.Transactions)) || args.Index < 0 {
|
||||||
return NewValidationError("Index", "does not exist")
|
return NewValidationError("Index", "does not exist")
|
||||||
}
|
}
|
||||||
*reply = v.Transactions[args.Index]
|
*reply = br.Transactions[args.Index]
|
||||||
case "eth_getTransactionByBlockNumberAndIndex":
|
case "eth_getTransactionByBlockNumberAndIndex":
|
||||||
args := new(BlockNumIndexArgs)
|
args := new(BlockNumIndexArgs)
|
||||||
if err := json.Unmarshal(req.Params, &args); err != nil {
|
if err := json.Unmarshal(req.Params, &args); err != nil {
|
||||||
@ -339,18 +332,15 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := p.GetBlockByHash(args.Hash, false)
|
br := NewBlockRes(p.xeth().EthBlockByHash(args.Hash))
|
||||||
if err != nil {
|
|
||||||
return err
|
if args.Index > int64(len(br.Uncles)) || args.Index < 0 {
|
||||||
}
|
|
||||||
if args.Index > int64(len(v.Uncles)) || args.Index < 0 {
|
|
||||||
return NewValidationError("Index", "does not exist")
|
return NewValidationError("Index", "does not exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
uncle, err := p.GetBlockByHash(common.ToHex(v.Uncles[args.Index]), false)
|
uhash := common.ToHex(br.Uncles[args.Index])
|
||||||
if err != nil {
|
uncle := NewBlockRes(p.xeth().EthBlockByHash(uhash))
|
||||||
return err
|
|
||||||
}
|
|
||||||
*reply = uncle
|
*reply = uncle
|
||||||
case "eth_getUncleByBlockNumberAndIndex":
|
case "eth_getUncleByBlockNumberAndIndex":
|
||||||
args := new(BlockNumIndexArgs)
|
args := new(BlockNumIndexArgs)
|
||||||
@ -366,10 +356,9 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
|
|||||||
return NewValidationError("Index", "does not exist")
|
return NewValidationError("Index", "does not exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
uncle, err := p.GetBlockByHash(common.ToHex(v.Uncles[args.Index]), false)
|
uhash := common.ToHex(v.Uncles[args.Index])
|
||||||
if err != nil {
|
uncle := NewBlockRes(p.xeth().EthBlockByHash(uhash))
|
||||||
return err
|
|
||||||
}
|
|
||||||
*reply = uncle
|
*reply = uncle
|
||||||
case "eth_getCompilers":
|
case "eth_getCompilers":
|
||||||
c := []string{""}
|
c := []string{""}
|
||||||
|
Loading…
Reference in New Issue
Block a user