mirror of
https://github.com/logos-storage/nim-mysticeti.git
synced 2026-01-08 08:33:08 +00:00
create next round from last round
This commit is contained in:
parent
db46e9927f
commit
6250be0d97
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user