Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pricenode: configurable exclusion by provider currency #6227

Merged
merged 2 commits into from May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public abstract class ExchangeRateProvider extends PriceProvider<Set<ExchangeRat

private static Set<String> SUPPORTED_CRYPTO_CURRENCIES = new HashSet<>();
private static Set<String> SUPPORTED_FIAT_CURRENCIES = new HashSet<>();
private Set<String> providerExclusionList = new HashSet<>();
private final String name;
private final String prefix;
private final Environment env;
Expand All @@ -73,6 +74,18 @@ public ExchangeRateProvider(Environment env, String name, String prefix, Duratio
this.name = name;
this.prefix = prefix;
this.env = env;
List<String> 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<String> getSupportedFiatCurrencies() {
Expand All @@ -91,7 +104,10 @@ public Set<String> getSupportedFiatCurrencies() {
log.info("fiat currencies excluded: {}", validatedExclusionList);
log.info("fiat currencies supported: {}", SUPPORTED_FIAT_CURRENCIES.size());
}
return SUPPORTED_FIAT_CURRENCIES;
// filter out any provider specific ccy exclusions
return SUPPORTED_FIAT_CURRENCIES.stream()
.filter(ccy -> !providerExclusionList.contains(ccy.toUpperCase()))
.collect(Collectors.toSet());
}

public Set<String> getSupportedCryptoCurrencies() {
Expand Down
46 changes: 0 additions & 46 deletions pricenode/src/main/java/bisq/price/spot/providers/Huobi.java

This file was deleted.

1 change: 1 addition & 0 deletions pricenode/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,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=
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ public void getAllMarketPrices_withMultipleProviders_overlappingCurrencyCodes()
@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() {
Expand Down
36 changes: 0 additions & 36 deletions pricenode/src/test/java/bisq/price/spot/providers/HuobiTest.java

This file was deleted.