MCPcopy Index your code
hub / github.com/ccxt/ccxt / loadMarketsHelper

Method loadMarketsHelper

java/lib/src/main/java/io/github/ccxt/Exchange.java:1491–1532  ·  view source on GitHub ↗
(boolean reload)

Source from the content-addressed store, hash-verified

1489 }
1490
1491 public java.util.concurrent.CompletableFuture<Object> loadMarketsHelper(boolean reload) throws ExecutionException, InterruptedException {
1492
1493 if (!reload && this.markets != null) {
1494 if (this.markets_by_id == null) {
1495 return java.util.concurrent.CompletableFuture.completedFuture(this.setMarkets(this.markets));
1496 }
1497 return java.util.concurrent.CompletableFuture.completedFuture(this.markets);
1498 }
1499
1500 // Chain: fetchCurrencies (if supported) → fetchMarkets → setMarkets
1501 // No thread blocked at any point
1502 // The base describe() sets has['fetchCurrencies'] to "emulated" (a String) for
1503 // exchanges that don't override it (e.g., bit2c, bitbns, coincheck). A direct
1504 // (Boolean) cast on that String throws ClassCastException. Mirror the TS form
1505 // `this.has['fetchCurrencies'] === true`: only treat as true when the value is
1506 // an actual Boolean true.
1507 Object fetchCurrenciesFlag = (this.has != null) ? this.has.get("fetchCurrencies") : null;
1508 boolean hasFetchCurrencies = (fetchCurrenciesFlag instanceof Boolean) && (Boolean) fetchCurrenciesFlag;
1509
1510 java.util.concurrent.CompletableFuture<Object> currenciesFuture;
1511 if (hasFetchCurrencies) {
1512 currenciesFuture = this.fetchCurrencies();
1513 } else {
1514 currenciesFuture = java.util.concurrent.CompletableFuture.completedFuture(null);
1515 }
1516
1517 return currenciesFuture.thenCompose(currencies -> {
1518 if (currencies != null) {
1519 this.options.put("cachedCurrencies", currencies);
1520 }
1521 return this.fetchMarkets().thenApply(markets -> {
1522 this.options.remove("cachedCurrencies");
1523 // Pass currencies through so setMarkets() can merge fetched currencies
1524 // (including ones not appearing as a base/quote/settle in any market —
1525 // e.g. AGLD/WBTC for bigone/apex, USDC for aftermath). The previous
1526 // form dropped this argument, forcing setMarkets to reconstruct the
1527 // currencies dict from market base/quote only and silently lose entries.
1528 return this.setMarkets(markets, currencies);
1529 });
1530 });
1531
1532 }
1533
1534 private final Object marketsLock = new Object();
1535

Callers 1

loadMarketsMethod · 0.95

Calls 5

setMarketsMethod · 0.95
fetchCurrenciesMethod · 0.95
fetchMarketsMethod · 0.95
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected