mirror of
https://github.com/logos-storage/nim-mysticeti.git
synced 2026-05-14 13:49:27 +00:00
move Rounds to rounds module
This commit is contained in:
parent
6250be0d97
commit
2dede094c8
@ -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:
|
||||
|
||||
@ -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]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user