RPCs: better errors when querying out of bound operations
This commit is contained in:
parent
42a8fbaf77
commit
79b4767370
@ -140,17 +140,22 @@ let build_raw_rpc_directory
|
|||||||
end ;
|
end ;
|
||||||
|
|
||||||
register1 S.Operations.operations_in_pass begin fun block i () () ->
|
register1 S.Operations.operations_in_pass begin fun block i () () ->
|
||||||
|
let chain_id = State.Block.chain_id block in
|
||||||
|
try
|
||||||
State.Block.operations block i >>= fun (ops, _path) ->
|
State.Block.operations block i >>= fun (ops, _path) ->
|
||||||
State.Block.operations_metadata block i >>= fun metadata ->
|
State.Block.operations_metadata block i >>= fun metadata ->
|
||||||
let chain_id = State.Block.chain_id block in
|
|
||||||
return (List.map2 (convert chain_id) ops metadata)
|
return (List.map2 (convert chain_id) ops metadata)
|
||||||
|
with _ -> Lwt.fail Not_found
|
||||||
end ;
|
end ;
|
||||||
|
|
||||||
register2 S.Operations.operation begin fun block i j () () ->
|
register2 S.Operations.operation begin fun block i j () () ->
|
||||||
|
let chain_id = State.Block.chain_id block in
|
||||||
|
begin try
|
||||||
State.Block.operations block i >>= fun (ops, _path) ->
|
State.Block.operations block i >>= fun (ops, _path) ->
|
||||||
State.Block.operations_metadata block i >>= fun metadata ->
|
State.Block.operations_metadata block i >>= fun metadata ->
|
||||||
let chain_id = State.Block.chain_id block in
|
Lwt.return (List.nth ops j, List.nth metadata j)
|
||||||
return (convert chain_id (List.nth ops j) (List.nth metadata j))
|
with _ -> Lwt.fail Not_found end >>= fun (op, md) ->
|
||||||
|
return (convert chain_id op md)
|
||||||
end ;
|
end ;
|
||||||
|
|
||||||
(* operation_hashes *)
|
(* operation_hashes *)
|
||||||
@ -165,8 +170,11 @@ let build_raw_rpc_directory
|
|||||||
end ;
|
end ;
|
||||||
|
|
||||||
register2 S.Operation_hashes.operation_hash begin fun block i j () () ->
|
register2 S.Operation_hashes.operation_hash begin fun block i j () () ->
|
||||||
|
begin try
|
||||||
State.Block.operation_hashes block i >>= fun (ops, _) ->
|
State.Block.operation_hashes block i >>= fun (ops, _) ->
|
||||||
return (List.nth ops j)
|
Lwt.return (List.nth ops j)
|
||||||
|
with _ -> Lwt.fail Not_found end >>= fun op ->
|
||||||
|
return op
|
||||||
end ;
|
end ;
|
||||||
|
|
||||||
(* context *)
|
(* context *)
|
||||||
|
Loading…
Reference in New Issue
Block a user