diff --git a/carnot/carnot-vote-aggregation.py b/carnot/carnot-vote-aggregation.py index d5e77ce..82536dd 100644 --- a/carnot/carnot-vote-aggregation.py +++ b/carnot/carnot-vote-aggregation.py @@ -263,3 +263,23 @@ class Carnot: else: return False + def update_high_qc(self, qc: Qc): + match (self.local_high_qc, qc): + case (None, new_qc) if isinstance(new_qc, StandardQc): + # Set local high QC to the new StandardQc + self.local_high_qc = new_qc + case (None, new_qc) if isinstance(new_qc, AggregateQc): + # Set local high QC to the high QC from the new AggregateQc + self.local_high_qc = new_qc.high_qc() + case (old_qc, new_qc) if isinstance(old_qc, StandardQc) and isinstance(new_qc, + StandardQc) and new_qc.view > old_qc.view: + # Update local high QC if the new StandardQc has a higher view + self.local_high_qc = new_qc + case (old_qc, new_qc) if isinstance(old_qc, AggregateQc) and isinstance(new_qc, + AggregateQc) and new_qc.high_qc().view != old_qc.view: + # Update local high QC if the view of the high QC in the new AggregateQc is different + self.local_high_qc = new_qc.high_qc() + + # If my view is not updated, I update it when I see a QC for that view + if qc.view == self.current_view: + self.current_view += 1