skynetcap/serum-data

Feature: Add multi-threading and retry when caching Tokens and Markets during startup

Closed this issue · 2 comments

Abstract

As of now, 2 getProgramAccounts RPC requests are made to a Solana RPC server on startup, first to cache the USDC markets, then the SOL markets. They are very slow, and can timeout, causing startup to fail.

Fix

  1. Add multi-threading to the 2 RPC calls, so they are made concurrently. CompleteableFuture may be preferred, or the most modern Java concurrency pattern that is elegant.
  2. If RPC timeout is experienced during either of the threads, retry up to 3 times.

Retry doesn't seem needed anymore, now that the majority of the Solana network is on 1.10.25, and both markets cache in ~1-3 seconds with the threading.

Resolved by 54e3351