RPC/Shell: make list_blocks tail-rec

This commit is contained in:
Vincent Botbol 2018-11-20 16:53:50 +01:00
parent eb673b19f2
commit dfb10047ef
No known key found for this signature in database
GPG Key ID: A2CE1BDBED95DA38

View File

@ -88,8 +88,8 @@ let list_blocks chain_state ?(length = 1) ?min_date heads =
| None -> Lwt.return (ignored, []) | None -> Lwt.return (ignored, [])
| Some block -> | Some block ->
predecessors ignored length block >>= fun predecessors -> predecessors ignored length block >>= fun predecessors ->
let ignored = let ignored = List.fold_left (fun acc v -> Block_hash.Set.add v acc)
List.fold_right Block_hash.Set.add predecessors ignored in ignored predecessors in
Lwt.return (ignored, predecessors :: acc)) Lwt.return (ignored, predecessors :: acc))
(Block_hash.Set.empty, []) (Block_hash.Set.empty, [])
requested_heads >>= fun (_, blocks) -> requested_heads >>= fun (_, blocks) ->
@ -169,6 +169,3 @@ let build_rpc_directory validator =
RPC_directory.prefix Chain_services.path @@ RPC_directory.prefix Chain_services.path @@
RPC_directory.map (fun ((), chain) -> get_chain state chain) !dir RPC_directory.map (fun ((), chain) -> get_chain state chain) !dir