wikideck/wikideck/StatusChecker/StatusChecker.py
Eric Meehan 14def28b68 Initial commit
Created basic application design and data schemas.
2025-05-28 19:24:37 -04:00

40 lines
1.4 KiB
Python

###
# The StatusChecker updates the market database based on the mine database.
# It will periodically query for pending transactions, and then confirm their status against
# the Mine API.
# It will also update user balances upon transaction completion.
###
class StatusChecker():
def __init__(self):
return
def update_pending_transactions(self):
for pendingTransaction in self.db.get_pending_transactions():
self.check_transaction_status(pendingTransaction)
def check_transaction_status(transaction):
transaction = Transaction(
data = transaction
)
# TODO: get transaction data from mine
if not mine_transaction.is_pending:
db.update_transaction_pending_status(
transactionId=transactionId,
is_pending=False
)
if not mine_transaction.block_id:
raise Transaction.Abandoned(
f"Transaction {pendingTransaction.transactionId} was abandoned."
)
else:
# TODO: increase seller balance by (price - fee)
# TODO: increase market balance by (fee)
return
if __name__ == '__main__':
statusChecker = StatusChecker()
while True:
transactionStatusChecker.update_pending_transactions()
time.sleep(INTERVAL)