Module Mavryk_baking_001_PtAtLas.Baking_scheduling

type loop_state
val create_loop_state : ?get_valid_blocks_stream:Baking_state.proposal Lwt_stream.t Lwt.t -> heads_stream:Baking_state.proposal Lwt_stream.t -> forge_event_stream:Baking_state.forge_event Lwt_stream.t -> Operation_worker.t -> loop_state
val sleep_until : Mavryk_base.TzPervasives.Time.Protocol.t -> unit Lwt.t option
val retry : Mavryk_client_001_PtAtLas.Protocol_client_context.full -> ?max_delay:float -> delay:float -> factor:float -> tries:int -> ?msg:string -> ('a -> 'b Mavryk_base.TzPervasives.tzresult Lwt.t) -> 'a -> 'b Mavryk_base.TzPervasives.tzresult Lwt.t

retry ctxt ~delay ?max_delay ~factor ~tries ?msg f x retries applying f x tries until it succeeds or returns an error different from Connection_failed, at most tries number of times. After each try it waits for a number of seconds, but not more than max_delay, if given. The wait time between tries is given by the initial delay, multiplied by factor at each subsequent try. At each failure, msg together with the current delay is printed using ctxt#message.

val wait_next_event : timeout:[ `Timeout of Baking_state.timeout_kind ] Lwt.t -> loop_state -> (Baking_state.event option, Mavryk_base.TzPervasives.error Mavryk_base.TzPervasives.trace) Stdlib.result Lwt.t

An event monitor using the streams in loop_state (to create promises) and a timeout promise timeout. The function reacts to a promise being fulfilled by firing an event Baking_state.event.

Returns the first round at the next level, at or after earliest_round, whose baking slot belongs to one of our own delegates; also returns the corresponding delegate. Or returns None if no such round exists.

val automaton_loop : ?stop_on_event:(Baking_state.event -> bool) -> config:Baking_configuration.t -> on_error: (Mavryk_base.TzPervasives.tztrace -> (unit, Mavryk_base.TzPervasives.tztrace) Stdlib.result Lwt.t) -> loop_state -> Baking_state.state -> Baking_state.event -> Baking_state.event option Mavryk_base.TzPervasives.tzresult Lwt.t