diff --git a/core/src/main/java/bisq/core/provider/price/PriceFeedService.java b/core/src/main/java/bisq/core/provider/price/PriceFeedService.java index 72c2989a12a..5f6cae191a5 100644 --- a/core/src/main/java/bisq/core/provider/price/PriceFeedService.java +++ b/core/src/main/java/bisq/core/provider/price/PriceFeedService.java @@ -394,21 +394,17 @@ private void requestAllPrices(PriceProvider provider, Runnable resultHandler, Fa } priceRequest = new PriceRequest(); - SettableFuture, Map>> future = priceRequest.requestAllPrices(provider); + SettableFuture> future = priceRequest.requestAllPrices(provider); Futures.addCallback(future, new FutureCallback<>() { @Override - public void onSuccess(@Nullable Tuple2, Map> result) { + public void onSuccess(@Nullable Map result) { UserThread.execute(() -> { checkNotNull(result, "Result must not be null at requestAllPrices"); // Each currency rate has a different timestamp, depending on when // the priceNode aggregate rate was calculated // However, the request timestamp is when the pricenode was queried epochInMillisAtLastRequest = System.currentTimeMillis(); - - Map priceMap = result.second; - - cache.putAll(priceMap); - + cache.putAll(result); resultHandler.run(); }); } diff --git a/core/src/main/java/bisq/core/provider/price/PriceProvider.java b/core/src/main/java/bisq/core/provider/price/PriceProvider.java index 3a69bb0f61b..335e8bf0cf8 100644 --- a/core/src/main/java/bisq/core/provider/price/PriceProvider.java +++ b/core/src/main/java/bisq/core/provider/price/PriceProvider.java @@ -48,9 +48,9 @@ public PriceProvider(HttpClient httpClient, String baseUrl) { super(httpClient, baseUrl, false); } - public Tuple2, Map> getAll() throws IOException { + public Map getAll() throws IOException { if (shutDownRequested) { - return new Tuple2<>(new HashMap<>(), new HashMap<>()); + return new HashMap<>(); } Map marketPriceMap = new HashMap<>(); @@ -61,13 +61,7 @@ public Tuple2, Map> getAll() throws IOExc String json = httpClient.get("getAllMarketPrices", "User-Agent", "bisq/" + Version.VERSION + hsVersion); - LinkedTreeMap map = new Gson().fromJson(json, LinkedTreeMap.class); - Map tsMap = new HashMap<>(); - tsMap.put("btcAverageTs", ((Double) map.get("btcAverageTs")).longValue()); - tsMap.put("poloniexTs", ((Double) map.get("poloniexTs")).longValue()); - tsMap.put("coinmarketcapTs", ((Double) map.get("coinmarketcapTs")).longValue()); - List list = (ArrayList) map.get("data"); list.forEach(obj -> { try { @@ -83,7 +77,7 @@ public Tuple2, Map> getAll() throws IOExc } }); - return new Tuple2<>(tsMap, marketPriceMap); + return marketPriceMap; } public String getBaseUrl() { diff --git a/core/src/main/java/bisq/core/provider/price/PriceRequest.java b/core/src/main/java/bisq/core/provider/price/PriceRequest.java index fa1a4279a66..7c9132f8b44 100644 --- a/core/src/main/java/bisq/core/provider/price/PriceRequest.java +++ b/core/src/main/java/bisq/core/provider/price/PriceRequest.java @@ -45,17 +45,17 @@ public class PriceRequest { public PriceRequest() { } - public SettableFuture, Map>> requestAllPrices(PriceProvider provider) { + public SettableFuture> requestAllPrices(PriceProvider provider) { this.provider = provider; String baseUrl = provider.getBaseUrl(); - SettableFuture, Map>> resultFuture = SettableFuture.create(); - ListenableFuture, Map>> future = executorService.submit(() -> { + SettableFuture> resultFuture = SettableFuture.create(); + ListenableFuture> future = executorService.submit(() -> { Thread.currentThread().setName(Thread.currentThread().getName() + "@" + baseUrl); return provider.getAll(); }); Futures.addCallback(future, new FutureCallback<>() { - public void onSuccess(Tuple2, Map> marketPriceTuple) { + public void onSuccess(Map marketPriceTuple) { log.trace("Received marketPriceTuple of {}\nfrom provider {}", marketPriceTuple, provider); if (!shutDownRequested) { resultFuture.set(marketPriceTuple);