Skip to content

perf(contract_tools): optimize balance fetching by batching Horizon r…#162

Open
Nemenwq wants to merge 2 commits into
Quantarq:mainfrom
Nemenwq:Horizon
Open

perf(contract_tools): optimize balance fetching by batching Horizon r…#162
Nemenwq wants to merge 2 commits into
Quantarq:mainfrom
Nemenwq:Horizon

Conversation

@Nemenwq

@Nemenwq Nemenwq commented Jun 22, 2026

Copy link
Copy Markdown

…equests

Description

Related Issue

closes #60

Change Type

I have optimized the way token balances are fetched from the Stellar network. Previously, the system made sequential HTTP requests for each supported token. Now, it fetches the entire account data in a single call and extracts all relevant balances.

Changes Made
blockchain_call.py
Added
_get_account_data
: A new private helper method that fetches and parses the full account data from the Stellar Horizon API. It handles 404 (account not found) and other network errors gracefully.
Refactored
get_token_balances
: Now calls
_get_account_data
once and iterates through the returned balances to find all supported tokens.
Refactored
fetch_portfolio
: Similar optimization applied to the portfolio fetching logic, ensuring only one network request is made instead of one per token.

  • feat — new feature
  • fix — bug fix
  • docs — documentation
  • refactor — code refactoring
  • test — adding or updating tests
  • ci — CI/CD changes

Testing Done

Screenshots (if UI changes)

Checklist

  • Tests pass (poetry run pytest)
  • Code passes linting (pylint)
  • Documentation updated (if applicable)
  • PR is linked to a related issue

@YaronZaki

Copy link
Copy Markdown
Contributor

@Nemenwq resolve conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: Batch Stellar Horizon balance queries instead of sequential per-token calls

2 participants