Skip to content

Commit

Permalink
Add an API with the ability to remove a tx from anywhere in the queue…
Browse files Browse the repository at this point in the history
…; this is handy when the user is notified about a failed tx and doesn't want to stall other txs from executing. Only the user has the context to make that decision, not ATxM.
  • Loading branch information
derekpierre committed Apr 4, 2024
1 parent 55f3b0e commit d383fcf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions atxm/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,12 @@ def queue_transaction(
self._wake()

return tx

def remove_queued_transaction(self, tx: FutureTx):
"""
Removes a queued transaction; useful when an exisitng queued transaction has broadcast
failures, or a queued transaction is no longer necessary.
Returns true if transaction was present and removed, false otherwise.
"""
return self._tx_tracker.remove_queued_tx(tx)
7 changes: 7 additions & 0 deletions atxm/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,10 @@ def queue_tx(
f"[tracker] queued transaction #atx-{tx.id} priority {len(self.__queue)}"
)
return tx

def remove_queued_tx(self, tx: FutureTx) -> bool:
try:
self.__queue.remove(tx)
return True
except ValueError:
return False

0 comments on commit d383fcf

Please sign in to comment.