forked from cerc-io/plugeth
Guard from nil pointers
This commit is contained in:
parent
e402e1dc2e
commit
b86450aaae
@ -238,6 +238,10 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
br := NewBlockRes(api.xeth().EthBlockByHash(args.Hash), false)
|
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 {
|
if args.Index >= int64(len(br.Uncles)) || args.Index < 0 {
|
||||||
return NewValidationError("Index", "does not exist")
|
return NewValidationError("Index", "does not exist")
|
||||||
@ -256,6 +260,11 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
|
|||||||
block := api.xeth().EthBlockByNumber(args.BlockNumber)
|
block := api.xeth().EthBlockByNumber(args.BlockNumber)
|
||||||
v := NewBlockRes(block, true)
|
v := NewBlockRes(block, true)
|
||||||
|
|
||||||
|
if v == nil {
|
||||||
|
*reply = nil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if args.Index >= int64(len(v.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")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user