revert price feed changes of #129 due to error when all tests run

observing "error applying consumer" in alice console when all tests run
This commit is contained in:
woodser 2021-10-28 15:24:53 -04:00
parent 68e0bba6ac
commit 4d81d98e00
2 changed files with 7 additions and 7 deletions

View File

@ -27,6 +27,7 @@ import java.util.function.Consumer;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import static bisq.common.util.MathUtils.roundDouble; import static bisq.common.util.MathUtils.roundDouble;
import static bisq.core.locale.CurrencyUtil.isFiatCurrency;
import static java.lang.String.format; import static java.lang.String.format;
@Singleton @Singleton
@ -43,11 +44,14 @@ class CorePriceService {
public void getMarketPrice(String currencyCode, Consumer<Double> resultHandler) { public void getMarketPrice(String currencyCode, Consumer<Double> resultHandler) {
String upperCaseCurrencyCode = currencyCode.toUpperCase(); String upperCaseCurrencyCode = currencyCode.toUpperCase();
if (!isFiatCurrency(upperCaseCurrencyCode))
throw new IllegalStateException(format("%s is not a valid currency code", upperCaseCurrencyCode));
if (!priceFeedService.hasPrices()) if (!priceFeedService.hasPrices())
throw new IllegalStateException("price feed service has no prices"); throw new IllegalStateException("price feed service has no prices");
try { 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) { } catch (Throwable throwable) {
log.warn("Could not set currency code in PriceFeedService", throwable); log.warn("Could not set currency code in PriceFeedService", throwable);
} }

View File

@ -270,19 +270,15 @@ public class PriceFeedService {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public void setCurrencyCode(String currencyCode) { 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)) { if (this.currencyCode == null || !this.currencyCode.equals(currencyCode)) {
this.currencyCode = currencyCode; this.currencyCode = currencyCode;
currencyCodeProperty.set(currencyCode); currencyCodeProperty.set(currencyCode);
if (applyPriceToConsumer && priceConsumer != null) if (priceConsumer != null)
applyPriceToConsumer(); applyPriceToConsumer();
} }
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Getter // Getter
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////