mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-18 04:04:31 -05:00
set price feed state in UserThread
This commit is contained in:
parent
c55fb927f2
commit
c6b1d03283
@ -284,6 +284,7 @@ public class PriceFeedService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setHavenoMarketPrice(String currencyCode, Price price) {
|
private void setHavenoMarketPrice(String currencyCode, Price price) {
|
||||||
|
UserThread.await(() -> {
|
||||||
if (!cache.containsKey(currencyCode) || !cache.get(currencyCode).isExternallyProvidedPrice()) {
|
if (!cache.containsKey(currencyCode) || !cache.get(currencyCode).isExternallyProvidedPrice()) {
|
||||||
cache.put(currencyCode, new MarketPrice(currencyCode,
|
cache.put(currencyCode, new MarketPrice(currencyCode,
|
||||||
MathUtils.scaleDownByPowerOf10(price.getValue(), CurrencyUtil.isCryptoCurrency(currencyCode) ? CryptoMoney.SMALLEST_UNIT_EXPONENT : TraditionalMoney.SMALLEST_UNIT_EXPONENT),
|
MathUtils.scaleDownByPowerOf10(price.getValue(), CurrencyUtil.isCryptoCurrency(currencyCode) ? CryptoMoney.SMALLEST_UNIT_EXPONENT : TraditionalMoney.SMALLEST_UNIT_EXPONENT),
|
||||||
@ -291,6 +292,7 @@ public class PriceFeedService {
|
|||||||
false));
|
false));
|
||||||
updateCounter.set(updateCounter.get() + 1);
|
updateCounter.set(updateCounter.get() + 1);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -298,12 +300,13 @@ public class PriceFeedService {
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public void setCurrencyCode(String currencyCode) {
|
public void setCurrencyCode(String currencyCode) {
|
||||||
|
UserThread.await(() -> {
|
||||||
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 (priceConsumer != null)
|
if (priceConsumer != null) applyPriceToConsumer();
|
||||||
applyPriceToConsumer();
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -428,7 +431,7 @@ public class PriceFeedService {
|
|||||||
faultHandler.handleFault(errorMessage, new PriceRequestException(errorMessage));
|
faultHandler.handleFault(errorMessage, new PriceRequestException(errorMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCounter.set(updateCounter.get() + 1);
|
UserThread.await(() -> updateCounter.set(updateCounter.get() + 1));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user