Tezos_raw_protocol_012_Psithaca.Round_reprA round represents an iteration of the single-shot consensus algorithm.
Rounds can be seen as an infinite, 0-indexed, list of durations. The durations are generated by an arithmetic progression depending on Constants_repr.minimal_block_delay (its initial value, a.k.a the one for round 0) and Constants_repr.delay_increment_per_round (its common difference) .
Round identifiers are non-negative 32 bit integers. This interface ensures that no negative round can be created.
type t = roundval zero : tRound zero
val pred : t -> t Tezos_protocol_environment_012_Psithaca.Error_monad.tzresultPredecessor of the given round. Returns an error if applied to zero, as negative round are prohibited.
val of_int32 :
int32 ->
t Tezos_protocol_environment_012_Psithaca.Error_monad.tzresultBuilding a round from an int32. Returns an error if applied to a negative number.
val to_int32 : t -> int32val of_int :
int ->
t Tezos_protocol_environment_012_Psithaca.Error_monad.tzresultBuilding a round from an int. Returns an error if applied to a negative number or a number greater than Int32.max_int.
val to_int :
t ->
int Tezos_protocol_environment_012_Psithaca.Error_monad.tzresultBuilding an int from a round. Returns an error if the value does not fit in max_int. (current 32bit encodings always fit in int on 64bit architecture though).
val to_slot :
t ->
committee_size:int ->
Slot_repr.t Tezos_protocol_environment_012_Psithaca.Error_monad.tzresultReturns the slot corresponding to the given round r, that is r mod committee_size.
val encoding : t Tezos_protocol_environment_012_Psithaca.Data_encoding.tRound encoding. Be aware that decoding a negative 32 bit integer would lead to an exception.
val pp : Tezos_protocol_environment_012_Psithaca.Format.formatter -> t -> unitinclude Tezos_protocol_environment_012_Psithaca.Compare.S with type t := tmodule Map : Tezos_protocol_environment_012_Psithaca.Map.S with type key = tmodule Durations : sig ... endval level_offset_of_round :
Durations.t ->
round:t ->
Period_repr.t Tezos_protocol_environment_012_Psithaca.Error_monad.tzresultlevel_offset_of_round round_durations ~round:r represents the offset of the starting time of round r with respect to the start of the level. round = 0 1 2 3 r
|-----|-----|-----|-----|-----|--- ... ... --|------|------- | <-------------------------------------------> level_offset
val timestamp_of_round :
Durations.t ->
predecessor_timestamp:Time_repr.t ->
predecessor_round:t ->
round:t ->
Time_repr.t Tezos_protocol_environment_012_Psithaca.Error_monad.tzresulttimestamp_of_round round_durations ~predecessor_timestamp:pred_ts ~predecessor_round:pred_round ~round returns the starting time of round round given that the timestamp and the round of the block at the previous level is pred_ts and pred_round, respectively.
pred_round = 0 pred_round
|-----|.. ... --|--------|-- ... --|------- | | | | pred_ts | | start_of_cur_level | | |-----|------|-- ... --|-------|- cur_round = 0 1 | round | res_ts
Precisely, the resulting timestamp is: pred_ts + round_duration(pred_round) + level_offset_of_round(round).
val timestamp_of_another_round_same_level :
Durations.t ->
current_timestamp:Time_repr.t ->
current_round:t ->
considered_round:t ->
Time_repr.t Tezos_protocol_environment_012_Psithaca.Error_monad.tzresulttimestamp_of_another_round_same_level round_durations ~current_timestamp ~current_round ~considered_round returns the starting time of round considered_round.
start of current level current ts result | | | | | | |-----|----...--|-- ... ------|- | | | | cur_round = 0 1 current considered round round
It also works when considered_round is lower than current_round.
Precisely, the resulting timestamp is: current_timestamp - level_offset_of_round(current_round) + level_offset_of_round(considered_round).
val round_of_timestamp :
Durations.t ->
predecessor_timestamp:Time_repr.t ->
predecessor_round:t ->
timestamp:Time_repr.t ->
t Tezos_protocol_environment_012_Psithaca.Error_monad.tzresultround_of_timestamp round_durations ~predecessor_timestamp ~predecessor_round ~timestamp:ts returns the round to which the timestamp ts belongs to, given that the timestamp and the round of the block at the previous level is pred_ts and pred_round, respectively.
Precisely, the resulting round is: round_and_offset round_durations ~level_offset:diff where diff = ts - (predecessor_timestamp + round_duration(predecessor_round).
Returns an error when the timestamp is before the level start.
module Internals_for_test : sig ... end