From 8035162502cb4cc7cbae45d5b0a825424edc7d1e Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Fri, 27 May 2022 10:31:52 -0500 Subject: [PATCH] pricenode: configurable exclusion property for provider currency. --- .../bisq/price/spot/ExchangeRateProvider.java | 18 +++++++++++++++++- .../src/main/resources/application.properties | 1 + .../price/spot/ExchangeRateServiceTest.java | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java b/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java index c9b61fa79f..b19c04154c 100644 --- a/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java +++ b/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java @@ -64,6 +64,7 @@ public abstract class ExchangeRateProvider extends PriceProvider SUPPORTED_CRYPTO_CURRENCIES = new HashSet<>(); private static Set SUPPORTED_FIAT_CURRENCIES = new HashSet<>(); + private Set providerExclusionList = new HashSet<>(); private final String name; private final String prefix; private final Environment env; @@ -73,6 +74,18 @@ public abstract class ExchangeRateProvider extends PriceProvider excludedByProvider = + Arrays.asList(env.getProperty("bisq.price.fiatcurrency.excludedByProvider", "") + .toUpperCase().trim().split("\\s*,\\s*")); + for (String s: excludedByProvider) { + String[] splits = s.split(":"); + if (splits.length == 2 && splits[0].equalsIgnoreCase(name) && CurrencyUtil.isFiatCurrency(splits[1])) { + providerExclusionList.add(splits[1]); + } + } + if (providerExclusionList.size() > 0) { + log.info("{} specific exclusion list={}", name, providerExclusionList.toString()); + } } public Set getSupportedFiatCurrencies() { @@ -91,7 +104,10 @@ public abstract class ExchangeRateProvider extends PriceProvider !providerExclusionList.contains(ccy.toUpperCase())) + .collect(Collectors.toSet()); } public Set getSupportedCryptoCurrencies() { diff --git a/pricenode/src/main/resources/application.properties b/pricenode/src/main/resources/application.properties index 5f97b25cc6..5765f51ea4 100644 --- a/pricenode/src/main/resources/application.properties +++ b/pricenode/src/main/resources/application.properties @@ -9,4 +9,5 @@ bisq.price.mining.providers.mempoolHostname.3=mempool.ninja bisq.price.mining.providers.mempoolHostname.4=mempool.bisq.services # bisq.price.mining.providers.mempoolHostname.5=someHostOrIP bisq.price.fiatcurrency.excluded=LBP,ARS +bisq.price.fiatcurrency.excludedByProvider=HUOBI:BRL bisq.price.cryptocurrency.excluded= diff --git a/pricenode/src/test/java/bisq/price/spot/ExchangeRateServiceTest.java b/pricenode/src/test/java/bisq/price/spot/ExchangeRateServiceTest.java index c6c6c06ed3..cda5814322 100644 --- a/pricenode/src/test/java/bisq/price/spot/ExchangeRateServiceTest.java +++ b/pricenode/src/test/java/bisq/price/spot/ExchangeRateServiceTest.java @@ -166,8 +166,10 @@ public class ExchangeRateServiceTest { @Test public void getAllMarketPrices_withMultipleProviders_excludedCurrencyCodes() { String excludedCcyString = "LBP,USD,EUR"; + String providerExcludedCcyString = "HUOBI:BRL,BINANCE:GBP,BINANCE:SEK"; Environment mockedEnvironment = mock(Environment.class); when(mockedEnvironment.getProperty(eq("bisq.price.fiatcurrency.excluded"), anyString())).thenReturn(excludedCcyString); + when(mockedEnvironment.getProperty(eq("bisq.price.fiatcurrency.excludedByProvider"), anyString())).thenReturn(providerExcludedCcyString); class MockedExchangeRateProvider extends ExchangeRateProvider { MockedExchangeRateProvider() {