Skip to content

Commit

Permalink
Merge branch 'main' into 710-sim-fe-finality-window
Browse files Browse the repository at this point in the history
  • Loading branch information
kstroobants authored Dec 10, 2024
2 parents 5aec90b + b412609 commit b84672e
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions backend/consensus/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,33 +573,38 @@ def run_appeal_window_loop(self):
async def _appeal_window(self):
print(" ~ ~ ~ ~ ~ FINALITY WINDOW: ", self.finality_window_time)
while True:
with self.get_session() as session:
chain_snapshot = ChainSnapshot(session)
transactions_processor = TransactionsProcessor(session)
accepted_transactions = chain_snapshot.get_accepted_transactions()
for transaction in accepted_transactions:
transaction = transaction_from_dict(transaction)
if not transaction.appealed:
if (
int(time.time()) - transaction.timestamp_accepted
) > self.finality_window_time:
self.finalize_transaction(
try:
with self.get_session() as session:
chain_snapshot = ChainSnapshot(session)
transactions_processor = TransactionsProcessor(session)
accepted_transactions = chain_snapshot.get_accepted_transactions()
for transaction in accepted_transactions:
transaction = transaction_from_dict(transaction)
if not transaction.appealed:
if (
int(time.time()) - transaction.timestamp_accepted
) > self.finality_window_time:
self.finalize_transaction(
transaction,
transactions_processor,
)
session.commit()
else:
transactions_processor.set_transaction_appeal(
transaction.hash, False
)
self.commit_reveal_accept_transaction(
transaction,
transactions_processor,
lambda contract_address: contract_snapshot_factory(
contract_address, session, transaction
),
)
session.commit()
else:
transactions_processor.set_transaction_appeal(
transaction.hash, False
)
self.commit_reveal_accept_transaction(
transaction,
transactions_processor,
lambda contract_address: contract_snapshot_factory(
contract_address, session, transaction
),
)
session.commit()

except Exception as e:
print("Error running consensus", e)
print(traceback.format_exc())

await asyncio.sleep(1)

Expand Down

0 comments on commit b84672e

Please sign in to comment.