mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 11:39:29 +00:00
fetch prices repeatedly when run as daemon
This commit is contained in:
parent
a3a5b96c06
commit
a5f457d8e9
6 changed files with 12 additions and 8 deletions
|
@ -216,6 +216,7 @@ public class DomainInitialisation {
|
||||||
signedWitnessService.onAllServicesInitialized();
|
signedWitnessService.onAllServicesInitialized();
|
||||||
|
|
||||||
priceFeedService.setCurrencyCodeOnInit();
|
priceFeedService.setCurrencyCodeOnInit();
|
||||||
|
priceFeedService.startRequestingPrices();
|
||||||
|
|
||||||
filterManager.setFilterWarningHandler(filterWarningHandler);
|
filterManager.setFilterWarningHandler(filterWarningHandler);
|
||||||
filterManager.onAllServicesInitialized();
|
filterManager.onAllServicesInitialized();
|
||||||
|
|
|
@ -149,7 +149,7 @@ public class P2PNetworkSetup {
|
||||||
|
|
||||||
// We want to get early connected to the price relay so we call it already now
|
// We want to get early connected to the price relay so we call it already now
|
||||||
priceFeedService.setCurrencyCodeOnInit();
|
priceFeedService.setCurrencyCodeOnInit();
|
||||||
priceFeedService.initialRequestPriceFeed();
|
priceFeedService.requestPrices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -137,7 +137,7 @@ public class PriceFeedService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialRequestPriceFeed() {
|
public void requestPrices() {
|
||||||
request(false);
|
request(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,11 +145,14 @@ public class PriceFeedService {
|
||||||
return !cache.isEmpty();
|
return !cache.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestPriceFeed(Consumer<Double> resultHandler, FaultHandler faultHandler) {
|
public void startRequestingPrices() {
|
||||||
|
if (requestTimer == null) request(true); // ignore if already repeat requesting
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startRequestingPrices(Consumer<Double> resultHandler, FaultHandler faultHandler) {
|
||||||
this.priceConsumer = resultHandler;
|
this.priceConsumer = resultHandler;
|
||||||
this.faultHandler = faultHandler;
|
this.faultHandler = faultHandler;
|
||||||
|
startRequestingPrices();
|
||||||
request(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProviderNodeAddress() {
|
public String getProviderNodeAddress() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class MarketPriceFeedServiceTest {
|
||||||
public void testGetPrice() throws InterruptedException {
|
public void testGetPrice() throws InterruptedException {
|
||||||
PriceFeedService priceFeedService = new PriceFeedService(null, null, null);
|
PriceFeedService priceFeedService = new PriceFeedService(null, null, null);
|
||||||
priceFeedService.setCurrencyCode("EUR");
|
priceFeedService.setCurrencyCode("EUR");
|
||||||
priceFeedService.requestPriceFeed(tradeCurrency -> {
|
priceFeedService.startRequestingPrices(tradeCurrency -> {
|
||||||
log.debug(tradeCurrency.toString());
|
log.debug(tradeCurrency.toString());
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
},
|
},
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class MarketPricePresentation {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupMarketPriceFeed() {
|
private void setupMarketPriceFeed() {
|
||||||
priceFeedService.requestPriceFeed(price -> marketPrice.set(FormattingUtils.formatMarketPrice(price, priceFeedService.getCurrencyCode())),
|
priceFeedService.startRequestingPrices(price -> marketPrice.set(FormattingUtils.formatMarketPrice(price, priceFeedService.getCurrencyCode())),
|
||||||
(errorMessage, throwable) -> marketPrice.set(Res.get("shared.na")));
|
(errorMessage, throwable) -> marketPrice.set(Res.get("shared.na")));
|
||||||
|
|
||||||
marketPriceBinding = EasyBind.combine(
|
marketPriceBinding = EasyBind.combine(
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class Statistics {
|
||||||
public void onUpdatedDataReceived() {
|
public void onUpdatedDataReceived() {
|
||||||
// we need to have tor ready
|
// we need to have tor ready
|
||||||
log.info("onBootstrapComplete: we start requestPriceFeed");
|
log.info("onBootstrapComplete: we start requestPriceFeed");
|
||||||
priceFeedService.requestPriceFeed(price -> log.info("requestPriceFeed. price=" + price),
|
priceFeedService.startRequestingPrices(price -> log.info("requestPriceFeed. price=" + price),
|
||||||
(errorMessage, throwable) -> log.warn("Exception at requestPriceFeed: " + throwable.getMessage()));
|
(errorMessage, throwable) -> log.warn("Exception at requestPriceFeed: " + throwable.getMessage()));
|
||||||
|
|
||||||
tradeStatisticsManager.onAllServicesInitialized();
|
tradeStatisticsManager.onAllServicesInitialized();
|
||||||
|
|
Loading…
Reference in a new issue