From bb8ea4d16af2b65c85d5f749965a3e08c8d19623 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Thu, 26 Sep 2024 08:17:54 +0200 Subject: [PATCH] remove rounds that were fully committed --- mysticeti/validator.nim | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mysticeti/validator.nim b/mysticeti/validator.nim index 4a0bced..d9b0732 100644 --- a/mysticeti/validator.nim +++ b/mysticeti/validator.nim @@ -66,6 +66,16 @@ func nextRound*(validator: Validator) = validator.last = next previous.next = some next +func remove(validator: Validator, round: Round) = + if previous =? round.previous: + previous.next = round.next + else: + validator.first = !round.next + if next =? round.next: + next.previous = round.previous + else: + validator.last = !round.previous + func hasParent(blck: Block, round: uint64, author: CommitteeMember): bool = for parent in blck.parents: if parent.round == round and parent.author == author: @@ -147,4 +157,6 @@ iterator committed*(validator: Validator): auto = of ProposalStatus.commit: slot.status = ProposalStatus.committed yield slot.proposal - current = round.next + if not done: + validator.remove(round) + current = round.next