diff --git a/mysticeti/validator.nim b/mysticeti/validator.nim index 302fbc1..6e7dedb 100644 --- a/mysticeti/validator.nim +++ b/mysticeti/validator.nim @@ -96,14 +96,6 @@ func status*(validator: Validator, blck: Block): ?SlotStatus = func status*(validator: Validator, proposal: SignedBlock): ?SlotStatus = validator.status(proposal.blck) -func searchBackwards(round: Round, blockId: BlockId): auto = - if found =? round.find(blockId.round): - let slot = found[blockId.author] - for proposal in slot.proposals: - let blck = proposal.blck - if blck.id == blockId: - return some blck - func updateIndirect(validator: Validator, slot: ProposerSlot, round: Round) = without anchor =? round.findAnchor(): return @@ -118,7 +110,7 @@ func updateIndirect(validator: Validator, slot: ProposerSlot, round: Round) = if parent in slotProposal.certificates: slotProposal.certify(anchorProposal) return - without parentBlock =? round.searchBackwards(parent): + without parentBlock =? round.find(parent): discard todo.add(parentBlock.parents) slot.skip() diff --git a/mysticeti/validator/rounds.nim b/mysticeti/validator/rounds.nim index bea9eba..2acd74a 100644 --- a/mysticeti/validator/rounds.nim +++ b/mysticeti/validator/rounds.nim @@ -76,6 +76,14 @@ func find*(round: Round, number: uint64): ?Round = return none Round current = previous +func find*(round: Round, blockId: BlockId): auto = + if found =? round.find(blockId.round): + let slot = found[blockId.author] + for proposal in slot.proposals: + let blck = proposal.blck + if blck.id == blockId: + return some blck + func findAnchor*(round: Round): auto = var next = round.find(round.number + 3) while current =? next: