Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve wallet states concurrently in redemption service #828

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

evandrosaturnino
Copy link

Description

This PR updates the findWalletForRedemption function to retrieve all wallet states concurrently by using Promise.all rather than reading them one by one. This change reduces the redemption processing time from several minutes (6–7 minutes) down to approximately 15-20 seconds.

Key Changes

  • Retrieve wallet states concurrently using Promise.all.
  • After retrieval, iterate over the assembled data to select the appropriate wallet.
  • Preserve the existing logic for determining suitability based on live status, pending redemptions, and sufficient balance.

Impact

Type of change

  • 💅 Refactoring (Non-breaking Change)
  • 🐛 Bug fix (Non-breaking Change: Fixes an issue)
  • 🛠️ Chore (Non-breaking Change: Doc updates, pkg upgrades, typos, etc..

Notice

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

`Wallet is not in Live state ` +
// Using Promise.all, we retrieve all wallet states at once,
// significantly improving overall performance.
return Promise.all(bridgeWalletsByWalletPublicKeyHash).then(async (bridgeWallets) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The main issue with Promise.all is that one failure will fail the whole set. Do we have retries set up around this?

Copy link
Contributor

@Shadowfiend Shadowfiend Jan 31, 2025

Choose a reason for hiding this comment

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

(Of note: not morally opposed here and if we're feeling good about it I'm good with shipping it—it would require a full npm publish to include though, is that right?)

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.

2 participants