From afc1f85c739395627f0692676790ad233d9efd80 Mon Sep 17 00:00:00 2001 From: wiz Date: Sat, 7 Mar 2020 02:36:20 +0900 Subject: [PATCH 1/2] Remove CoinMarketCap as dead code --- .../price/spot/providers/CoinMarketCap.java | 77 ------------------- 1 file changed, 77 deletions(-) delete mode 100644 pricenode/src/main/java/bisq/price/spot/providers/CoinMarketCap.java diff --git a/pricenode/src/main/java/bisq/price/spot/providers/CoinMarketCap.java b/pricenode/src/main/java/bisq/price/spot/providers/CoinMarketCap.java deleted file mode 100644 index f5ce64f745..0000000000 --- a/pricenode/src/main/java/bisq/price/spot/providers/CoinMarketCap.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.price.spot.providers; - -import bisq.price.spot.ExchangeRate; -import bisq.price.spot.ExchangeRateProvider; -import bisq.price.util.Altcoins; - -import org.knowm.xchange.coinmarketcap.dto.marketdata.CoinMarketCapTicker; - -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.core.annotation.Order; -import org.springframework.http.RequestEntity; -import org.springframework.stereotype.Component; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -import java.time.Duration; - -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -@Component -@Order(3) -class CoinMarketCap extends ExchangeRateProvider { - - private final RestTemplate restTemplate = new RestTemplate(); - - public CoinMarketCap() { - super("CMC", "coinmarketcap", Duration.ofMinutes(5)); // large data structure, so don't request it too often - } - - @Override - public Set doGet() { - - return getTickers() - .filter(t -> Altcoins.ALL_SUPPORTED.contains(t.getIsoCode())) - .map(t -> - new ExchangeRate( - t.getIsoCode(), - t.getPriceBTC(), - t.getLastUpdated(), - this.getName() - ) - ) - .collect(Collectors.toSet()); - } - - private Stream getTickers() { - return restTemplate.exchange( - RequestEntity - .get(UriComponentsBuilder - .fromUriString("https://api.coinmarketcap.com/v1/ticker/?limit=200").build() - .toUri()) - .build(), - new ParameterizedTypeReference>() { - } - ).getBody().stream(); - } -} From cdf0a9b128e53daa8e224ea99700fa449fc27026 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Fri, 6 Mar 2020 19:16:33 +0100 Subject: [PATCH 2/2] Update Poloniex exchange rate provider @Order value With the removal of CoinMarketCap as an exchange rate provider in the prior commit, the @Order values of the remaining three provider implementations are non-contiguous. CoinMarketCap was @Order(3) and with it gone, the remaining order values became 1, 2, 4. This is not a problem in practice, but could be confusing for future maintainers, so this commit simply decrements the Poloniex implementation from 4 to 3 in order to make the values contiguous once again. This commit also fixes a typo in ExchangeRateProvider's Javadoc. --- .../src/main/java/bisq/price/spot/ExchangeRateProvider.java | 2 +- pricenode/src/main/java/bisq/price/spot/providers/Poloniex.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java b/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java index fc3e75cbf4..554fb0130c 100644 --- a/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java +++ b/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java @@ -30,7 +30,7 @@ import java.util.Set; * {@link org.springframework.core.annotation.Order} annotation to determine their * precedence over each other in the case of two or more services returning exchange rate * data for the same currency pair. In such cases, results from the provider with the - * higher order value will taking precedence over the provider with a lower value, + * higher order value will take precedence over the provider with a lower value, * presuming that such providers are being iterated over in an ordered list. * * @see ExchangeRateService#ExchangeRateService(java.util.List) diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Poloniex.java b/pricenode/src/main/java/bisq/price/spot/providers/Poloniex.java index 684f867b25..c62401492e 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Poloniex.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Poloniex.java @@ -42,7 +42,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Component -@Order(4) +@Order(3) class Poloniex extends ExchangeRateProvider { private final RestTemplate restTemplate = new RestTemplate();