Alpha/baker: wait for first block instead of error

This commit is contained in:
Raphaël Proust 2018-06-13 14:08:12 +08:00 committed by Grégoire Henry
parent 34aeaadb73
commit 46de116fe7

View File

@ -687,11 +687,16 @@ let create
?max_priority
(delegates: public_key_hash list)
(block_stream: Client_baking_blocks.block_info tzresult Lwt_stream.t) =
let rec wait_for_first_block () =
Lwt_stream.get block_stream >>= function
| None | Some (Error _) ->
cctxt#error "Can't fetch the current block head."
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 ()