From dfb10047effb96c95ba762e6a3bd7b8291e94504 Mon Sep 17 00:00:00 2001 From: Vincent Botbol Date: Tue, 20 Nov 2018 16:53:50 +0100 Subject: [PATCH] RPC/Shell: make list_blocks tail-rec --- src/lib_shell/chain_directory.ml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/lib_shell/chain_directory.ml b/src/lib_shell/chain_directory.ml index bb727225e..fa7a57f07 100644 --- a/src/lib_shell/chain_directory.ml +++ b/src/lib_shell/chain_directory.ml @@ -88,8 +88,8 @@ let list_blocks chain_state ?(length = 1) ?min_date heads = | None -> Lwt.return (ignored, []) | Some block -> predecessors ignored length block >>= fun predecessors -> - let ignored = - List.fold_right Block_hash.Set.add predecessors ignored in + let ignored = List.fold_left (fun acc v -> Block_hash.Set.add v acc) + ignored predecessors in Lwt.return (ignored, predecessors :: acc)) (Block_hash.Set.empty, []) requested_heads >>= fun (_, blocks) -> @@ -169,6 +169,3 @@ let build_rpc_directory validator = RPC_directory.prefix Chain_services.path @@ RPC_directory.map (fun ((), chain) -> get_chain state chain) !dir - - -