Skip to content

Commit

Permalink
code review: remove duplicated lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacxx committed Apr 6, 2022
1 parent 589404f commit 1482153
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions core/src/main/java/bisq/core/provider/price/PriceFeedService.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,7 @@ public MarketPrice getMarketPrice(String currencyCode) {
}

public void setBisqMarketPrice(String currencyCode, Price price) {
if (!cache.containsKey(currencyCode) || !cache.get(currencyCode).isExternallyProvidedPrice()) {
cache.put(currencyCode, new MarketPrice(currencyCode,
MathUtils.scaleDownByPowerOf10(price.getValue(), CurrencyUtil.isCryptoCurrency(currencyCode) ? 8 : 4),
0,
false));
if (applyPriceToCache(currencyCode, price)) {
updateCounter.set(updateCounter.get() + 1);
}
}
Expand Down Expand Up @@ -297,17 +293,21 @@ public Date getLastRequestTimeStamp() {
}

public void applyInitialBisqMarketPrice(Map<String, Price> priceByCurrencyCode) {
priceByCurrencyCode.forEach((currencyCode, price) -> {
if (!cache.containsKey(currencyCode) || !cache.get(currencyCode).isExternallyProvidedPrice()) {
cache.put(currencyCode, new MarketPrice(currencyCode,
MathUtils.scaleDownByPowerOf10(price.getValue(), CurrencyUtil.isCryptoCurrency(currencyCode) ? 8 : 4),
0,
false));
}
});
priceByCurrencyCode.forEach(this::applyPriceToCache);
updateCounter.set(updateCounter.get() + 1);
}

private boolean applyPriceToCache(String currencyCode, Price price) {
if (!cache.containsKey(currencyCode) || !cache.get(currencyCode).isExternallyProvidedPrice()) {
cache.put(currencyCode, new MarketPrice(currencyCode,
MathUtils.scaleDownByPowerOf10(price.getValue(), CurrencyUtil.isCryptoCurrency(currencyCode) ? 8 : 4),
0,
false));
return true;
}
return false;
}

public Optional<Price> getBsqPrice() {
MarketPrice bsqMarketPrice = getMarketPrice("BSQ");
if (bsqMarketPrice != null) {
Expand Down

0 comments on commit 1482153

Please sign in to comment.