mirror of
https://github.com/logos-co/nomos-specs.git
synced 2025-02-12 23:36:29 +00:00
Get max timeout by highQC
This commit is contained in:
parent
7d0e84fd32
commit
f55d897104
@ -68,7 +68,13 @@ class TimeoutQc:
|
||||
high_qc: AggregateQc
|
||||
|
||||
|
||||
Quorum: TypeAlias = Set[Vote] | Set[TimeoutQc]
|
||||
@dataclass
|
||||
class Timeout:
|
||||
view: View
|
||||
high_qc: Qc
|
||||
|
||||
|
||||
Quorum: TypeAlias = Set[Vote] | Set[Timeout]
|
||||
|
||||
|
||||
class Overlay:
|
||||
@ -294,6 +300,11 @@ class Carnot:
|
||||
self.current_view = qc.view + 1
|
||||
return True
|
||||
|
||||
def get_max_timeout(timeouts: List[Timeout]) -> Optional[Timeout]:
|
||||
if not timeouts:
|
||||
return None
|
||||
return max(timeouts, key=lambda time: time.qc.view)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
|
@ -208,7 +208,7 @@ class TestCarnotHappyPath(TestCase):
|
||||
self.assertEqual(carnot.highest_voted_view, 1)
|
||||
self.assertEqual(carnot.current_view, 1)
|
||||
|
||||
#2 If last_voted_view is incremented after calling vote.
|
||||
#2 If last_voted_view is incremented after calling vote with votes lower than.
|
||||
|
||||
def test_vote_for_received_block_if_threshold_votes_has_not_reached(self):
|
||||
class MockOverlay(Overlay):
|
||||
@ -236,11 +236,11 @@ class TestCarnotHappyPath(TestCase):
|
||||
view=1,
|
||||
block=block1.id(),
|
||||
qc=StandardQc(block=block1.id(), view=1)
|
||||
) for i in range(9)
|
||||
) for i in range(10)
|
||||
)
|
||||
carnot.vote(block1, votes)
|
||||
self.assertEqual(carnot.highest_voted_view, 0)
|
||||
self.assertEqual(carnot.current_view, 0)
|
||||
self.assertEqual(carnot.highest_voted_view, 1)
|
||||
self.assertEqual(carnot.current_view, 1)
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user