RPC/Shell: make list_blocks tail-rec
This commit is contained in:
parent
eb673b19f2
commit
dfb10047ef
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user