From 1e1b92211094da1c60a698796a370cea3be8393d Mon Sep 17 00:00:00 2001 From: Guillaume Genestier Date: Thu, 22 May 2025 18:46:55 +0200 Subject: [PATCH] DAL: use find_map_es rather than an error to look for first URI storing looked for slot --- src/lib_dal_node/slot_manager.ml | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/lib_dal_node/slot_manager.ml b/src/lib_dal_node/slot_manager.ml index 6f1d9422690c..86450eb98b81 100644 --- a/src/lib_dal_node/slot_manager.ml +++ b/src/lib_dal_node/slot_manager.ml @@ -290,26 +290,21 @@ let fetch_slot_from_http_backups ctxt cryptobox ~slot_size slot_id = if config.trust_http_backup_uris then return_none else get_commitment_from_slot_id ctxt slot_id in - (* In the iter below, we "fail" to exit the loop as soon as a correct slot - content is fetched. *) - let*! res = - List.iter_es + let* slot_opt = + List.find_map_es (fun uri -> - let*! res = - try_fetch_slot_from_http_backup - cryptobox - ~slot_size - ~published_level - ~slot_index - expected_commitment_hash - uri - in - match res with Ok (Some slot) -> fail slot | _ -> return_unit) + try_fetch_slot_from_http_backup + cryptobox + ~slot_size + ~published_level + ~slot_index + expected_commitment_hash + uri) http_backup_uris in - match res with - | Ok () -> fail Errors.not_found - | Error slot -> return slot) + match slot_opt with + | None -> fail Errors.not_found + | Some slot -> return slot) let get_slot_content ~reconstruct_if_missing ctxt slot_id = let open Lwt_result_syntax in -- GitLab