From 98513f8c5f01c26696eff1c770cdc8b36f11e21d Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 15 Apr 2024 18:07:21 -0400 Subject: [PATCH] finalize transactions fix --- src/dexorder/transaction.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/dexorder/transaction.py b/src/dexorder/transaction.py index 026403a..b88e7ee 100644 --- a/src/dexorder/transaction.py +++ b/src/dexorder/transaction.py @@ -118,17 +118,14 @@ async def handle_transaction_receipts(): def finalize_transactions(_fork: Fork, diffs: list[DiffEntryItem]): - open_txs = set(db.session.scalars(select(TransactionJob.tx_id).where( - TransactionJob.chain == current_chain.get(), - TransactionJob.state == TransactionJobState.Sent - )).all()) + open_jobs = db.session.scalars(select(TransactionJob).where( + TransactionJob.chain == current_chain.get(), + TransactionJob.state == TransactionJobState.Sent + )).all() + open_txs = {job.tx_id:job for job in open_jobs} for diff in diffs: if diff.series == 'mined_txs' and diff.key in open_txs: - job = db.session.scalar(TransactionJob).where( - TransactionJob.chain == current_chain.get(), - TransactionJob.state == TransactionJobState.Sent, - TransactionJob.tx_id == diff.key - ).one() + job = open_txs[diff.key] job.state = TransactionJobState.Mined job.receipt = diff.value db.session.add(job)