move Rounds to rounds module

This commit is contained in:
Mark Spanbroek 2024-10-17 14:46:40 +02:00
parent 6250be0d97
commit 2dede094c8
2 changed files with 17 additions and 16 deletions

View File

@ -13,8 +13,6 @@ type
committee: Committee[Signing]
membership: CommitteeMember
rounds: Rounds[Hashing]
Rounds[Hashing] = object
first, last: Round[Hashing]
func new*(T: type Validator; identity: Identity, committee: Committee): ?!T =
let round = Round[T.Hashing].new(0, committee.size)
@ -61,16 +59,6 @@ func wave(rounds: Rounds): auto =
func nextRound*(validator: Validator) =
validator.rounds.last = validator.rounds.last.createNext()
func remove(rounds: var Rounds, round: Round) =
if previous =? round.previous:
previous.next = round.next
else:
rounds.first = !round.next
if next =? round.next:
next.previous = round.previous
else:
rounds.last = !round.previous
func skips(blck: Block, round: uint64, author: CommitteeMember): bool =
for parent in blck.parents:
if parent.round == round and parent.author == author:

View File

@ -1,10 +1,23 @@
import ../basics
import ./slots
type Round*[Hashing] = ref object
number: uint64
previous*, next*: ?Round[Hashing]
slots*: seq[ProposerSlot[Hashing]]
type
Rounds*[Hashing] = object
first*, last*: Round[Hashing]
Round*[Hashing] = ref object
number: uint64
previous*, next*: ?Round[Hashing]
slots*: seq[ProposerSlot[Hashing]]
func remove*(rounds: var Rounds, round: Round) =
if previous =? round.previous:
previous.next = round.next
else:
rounds.first = !round.next
if next =? round.next:
next.previous = round.previous
else:
rounds.last = !round.previous
func new*(T: type Round, number: uint64, slots: int): T =
type Slot = ProposerSlot[T.Hashing]