Skip to content

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

Merged
YaronZaki merged 3 commits into
Quantarq:mainfrom
Nemenwq:Horizon
Jun 27, 2026
Merged

perf(contract_tools): optimize balance fetching by batching Horizon r…#162
YaronZaki merged 3 commits into
Quantarq:mainfrom
Nemenwq:Horizon

Conversation

@Nemenwq

@Nemenwq Nemenwq commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

…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.

@Nemenwq

Nemenwq commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

@YaronZaki done. please review

@YaronZaki YaronZaki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@YaronZaki YaronZaki merged commit 5606365 into Quantarq:main Jun 27, 2026
3 checks passed
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