fix block commit function

This commit is contained in:
Giacomo Pasini 2023-04-11 12:00:19 +02:00
parent 679902e4cc
commit b403251ace
No known key found for this signature in database
GPG Key ID: FC08489D2D895D4B
1 changed files with 14 additions and 13 deletions

View File

@ -532,19 +532,20 @@ class Carnot:
parent = self.safe_blocks.get(block.parent()) parent = self.safe_blocks.get(block.parent())
grand_parent = self.safe_blocks.get(parent.parent()) grand_parent = self.safe_blocks.get(parent.parent())
while grand_parent and grand_parent.view > self.latest_committed_view: # this case should just trigger on genesis_case,
# this case should just trigger on genesis_case, # as the preconditions on outer calls should check on block validity
# as the preconditions on outer calls should check on block validity if not parent or not grand_parent:
if not parent or not grand_parent: return
return can_commit = (
can_commit = ( parent.view == (grand_parent.view + 1) and
parent.view == (grand_parent.view + 1) and isinstance(block.qc, (StandardQc,)) and
isinstance(block.qc, (StandardQc,)) and isinstance(parent.qc, (StandardQc,))
isinstance(parent.qc, (StandardQc,)) )
) # Manually commit all the chain between a newly committed block and the previous highest
if can_commit: # committed block.
self.committed_blocks[grand_parent.id()] = grand_parent while can_commit and grand_parent and grand_parent.view > self.latest_committed_view:
self.increment_latest_committed_view(grand_parent.view) self.committed_blocks[grand_parent.id()] = grand_parent
self.increment_latest_committed_view(grand_parent.view)
grand_parent = self.safe_blocks.get(grand_parent.parent()) grand_parent = self.safe_blocks.get(grand_parent.parent())
def increment_voted_view(self, view: View): def increment_voted_view(self, view: View):