From fed7b22c90b50524c1f290f1419b1df4d854d9a4 Mon Sep 17 00:00:00 2001 From: erciccione Date: Thu, 4 Aug 2022 08:59:06 +0200 Subject: [PATCH] pricenode: woodser's patch --- .../java/bisq/core/provider/price/PriceProvider.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 f6072351..199849f5 100644 --- a/core/src/main/java/bisq/core/provider/price/PriceProvider.java +++ b/core/src/main/java/bisq/core/provider/price/PriceProvider.java @@ -64,9 +64,9 @@ public class PriceProvider extends HttpClientProvider { 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()); + transfer("btcAverageTs", map, tsMap); + transfer("poloniexTs", map, tsMap); + transfer("coinmarketcapTs", map, tsMap); // get btc per xmr price to convert all prices to xmr // TODO (woodser): currently using bisq price feed, switch? @@ -99,6 +99,12 @@ public class PriceProvider extends HttpClientProvider { return new Tuple2<>(tsMap, marketPriceMap); } + private void transfer(String key, LinkedTreeMap map, Map tsMap) { + if (map.containsKey(key)) tsMap.put(key, ((Double) map.get(key)).longValue()); + else log.warn("No prices returned from provider " + key); + } + + /** * @return price of 1 XMR in BTC */