From 4d81d98e00a20756a532c3db045aa1d17fe8a674 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 28 Oct 2021 15:24:53 -0400 Subject: [PATCH] revert price feed changes of #129 due to error when all tests run observing "error applying consumer" in alice console when all tests run --- core/src/main/java/bisq/core/api/CorePriceService.java | 6 +++++- .../java/bisq/core/provider/price/PriceFeedService.java | 8 ++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/bisq/core/api/CorePriceService.java b/core/src/main/java/bisq/core/api/CorePriceService.java index c572409b46..4553689e98 100644 --- a/core/src/main/java/bisq/core/api/CorePriceService.java +++ b/core/src/main/java/bisq/core/api/CorePriceService.java @@ -27,6 +27,7 @@ import java.util.function.Consumer; import lombok.extern.slf4j.Slf4j; import static bisq.common.util.MathUtils.roundDouble; +import static bisq.core.locale.CurrencyUtil.isFiatCurrency; import static java.lang.String.format; @Singleton @@ -43,11 +44,14 @@ class CorePriceService { public void getMarketPrice(String currencyCode, Consumer resultHandler) { String upperCaseCurrencyCode = currencyCode.toUpperCase(); + if (!isFiatCurrency(upperCaseCurrencyCode)) + throw new IllegalStateException(format("%s is not a valid currency code", upperCaseCurrencyCode)); + if (!priceFeedService.hasPrices()) throw new IllegalStateException("price feed service has no prices"); try { - priceFeedService.setCurrencyCode(upperCaseCurrencyCode, false); // TODO (woodser): skipping applying to consumer to avoid console warning spam when getting market prices over the api + priceFeedService.setCurrencyCode(upperCaseCurrencyCode); } catch (Throwable throwable) { log.warn("Could not set currency code in PriceFeedService", throwable); } 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 ab28cac38e..0ef06b65f8 100644 --- a/core/src/main/java/bisq/core/provider/price/PriceFeedService.java +++ b/core/src/main/java/bisq/core/provider/price/PriceFeedService.java @@ -270,19 +270,15 @@ public class PriceFeedService { /////////////////////////////////////////////////////////////////////////////////////////// public void setCurrencyCode(String currencyCode) { - setCurrencyCode(currencyCode, true); - } - - // TODO (woodser): necessary to skip applying to consumer to avoid console warning spam when getting market prices over the api - public void setCurrencyCode(String currencyCode, boolean applyPriceToConsumer) { if (this.currencyCode == null || !this.currencyCode.equals(currencyCode)) { this.currencyCode = currencyCode; currencyCodeProperty.set(currencyCode); - if (applyPriceToConsumer && priceConsumer != null) + if (priceConsumer != null) applyPriceToConsumer(); } } + /////////////////////////////////////////////////////////////////////////////////////////// // Getter ///////////////////////////////////////////////////////////////////////////////////////////