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 ?max_priority
(delegates: public_key_hash list) (delegates: public_key_hash list)
(block_stream: Client_baking_blocks.block_info tzresult Lwt_stream.t) = (block_stream: Client_baking_blocks.block_info tzresult Lwt_stream.t) =
Lwt_stream.get block_stream >>= function let rec wait_for_first_block () =
| None | Some (Error _) -> Lwt_stream.get block_stream >>= function
cctxt#error "Can't fetch the current block head." | None | Some (Error _) ->
| Some (Ok bi) -> cctxt#message "Can't fetch the current block head. Retrying soon." >>= fun () ->
create (* NOTE: this is not a tight loop because of Lwt_stream.get *)
cctxt ?max_priority delegates wait_for_first_block ()
block_stream bi | Some (Ok bi) ->
create
cctxt ?max_priority delegates
block_stream bi
in
wait_for_first_block ()