From 46de116fe714afad5201366df286df40c425c21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Wed, 13 Jun 2018 14:08:12 +0800 Subject: [PATCH] Alpha/baker: wait for first block instead of error --- .../lib_delegate/client_baking_forge.ml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index 86d21554b..e6c31d213 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -687,11 +687,16 @@ let create ?max_priority (delegates: public_key_hash list) (block_stream: Client_baking_blocks.block_info tzresult Lwt_stream.t) = - Lwt_stream.get block_stream >>= function - | None | Some (Error _) -> - cctxt#error "Can't fetch the current block head." - | Some (Ok bi) -> - create - cctxt ?max_priority delegates - block_stream bi + let rec wait_for_first_block () = + Lwt_stream.get block_stream >>= function + | None | Some (Error _) -> + cctxt#message "Can't fetch the current block head. Retrying soon." >>= fun () -> + (* NOTE: this is not a tight loop because of Lwt_stream.get *) + wait_for_first_block () + | Some (Ok bi) -> + create + cctxt ?max_priority delegates + block_stream bi + in + wait_for_first_block ()