diff --git a/mysticeti/validator.nim b/mysticeti/validator.nim index 9bf5904..916e056 100644 --- a/mysticeti/validator.nim +++ b/mysticeti/validator.nim @@ -59,12 +59,7 @@ func wave(rounds: Rounds): auto = none (Round, Round, Round) func nextRound*(validator: Validator) = - type Round = typeof(validator.rounds.last) - let previous = validator.rounds.last - let next = Round.new(previous.number + 1, validator.committee.size) - next.previous = some previous - previous.next = some next - validator.rounds.last = next + validator.rounds.last = validator.rounds.last.createNext() func remove(rounds: var Rounds, round: Round) = if previous =? round.previous: diff --git a/mysticeti/validator/rounds.nim b/mysticeti/validator/rounds.nim index af4ec0c..5128ff0 100644 --- a/mysticeti/validator/rounds.nim +++ b/mysticeti/validator/rounds.nim @@ -11,5 +11,12 @@ func new*(T: type Round, number: uint64, slots: int): T = let slots = newSeqWith(slots, Slot.new()) T(number: number, slots: slots) +func createNext*(round: Round): auto = + assert round.next.isNone + let next = Round.new(round.number + 1, round.slots.len) + next.previous = some round + round.next = some next + next + func number*(round: Round): uint64 = round.number