feat: Replace most prints with logger calls to help with debugging
All checks were successful
Tests and Linting / Tests-Linting (3.10) (push) Successful in 32s
Tests and Linting / Tests-Linting (3.13) (push) Successful in 32s
Tests and Linting / Tests-Linting (3.11) (push) Successful in 34s
Build Docker / Build Images (map[dockerfile:Dockerfile tag_suffix: target:default]) (push) Successful in 48s
Build Docker / Build Images (map[dockerfile:Dockerfile.hsd tag_suffix:-hsd target:hsd]) (push) Successful in 50s

This commit is contained in:
2025-09-10 17:14:32 +10:00
parent 63e0f0b804
commit 9f8daa8b88
2 changed files with 25 additions and 17 deletions

View File

@@ -352,6 +352,7 @@ def getBalance(account: str):
# Get the total balance
info = hsw.getBalance('default', account)
if 'error' in info:
logger.error(f"Error getting balance for account {account}: {info['error']}")
return {'available': 0, 'total': 0}
total = info['confirmed']
@@ -361,6 +362,7 @@ def getBalance(account: str):
# Convert to HNS
total = total / 1000000
available = available / 1000000
logger.debug(f"Initial balance for account {account}: total={total}, available={available}, locked={locked}")
domains = getDomains(account)
domainValue = 0
@@ -404,6 +406,7 @@ def getBalance(account: str):
if domain_info.get('info', {}).get('state', "") == "CLOSED":
domainValue += domain_info.get('info', {}).get('value', 0)
except json.JSONDecodeError:
logger.warning(f"Error parsing cached data for domain {domain_name}")
# Only add for update if not already being updated
with DOMAIN_UPDATE_LOCK:
if domain_name not in ACTIVE_DOMAIN_UPDATES:
@@ -423,9 +426,10 @@ def getBalance(account: str):
daemon=True
)
thread.start()
total = total - (domainValue/1000000)
locked = locked - (domainValue/1000000)
logger.debug(f"Adjusted balance for account {account}: total={total}, available={available}, locked={locked}")
# Only keep 2 decimal places
total = round(total, 2)