VoteTiming
Library to compute rounds and phases for an equal length commit-reveal voting cycle.
init(struct VoteTiming.Data data, uint256 phaseLength)
internal
Initializes the data object. Sets the phase length based on the input.
computeCurrentRoundId(struct VoteTiming.Data data, uint256 currentTime) → uint256
internal
Computes the roundID based off the current time as floor(timestamp/roundLength).
The round ID depends on the global timestamp but not on the lifetime of the system. The consequence is that the initial round ID starts at an arbitrary number (that increments, as expected, for subsequent rounds) instead of zero or one.
Parameters:
-
data
: input data object. -
currentTime
: input unix timestamp used to compute the current roundId.