fetch prices repeatedly when run as daemon

This commit is contained in:
woodser 2022-07-28 15:45:47 -04:00
parent a3a5b96c06
commit a5f457d8e9
6 changed files with 12 additions and 8 deletions

View file

@ -216,6 +216,7 @@ public class DomainInitialisation {
signedWitnessService.onAllServicesInitialized();
priceFeedService.setCurrencyCodeOnInit();
priceFeedService.startRequestingPrices();
filterManager.setFilterWarningHandler(filterWarningHandler);
filterManager.onAllServicesInitialized();

View file

@ -149,7 +149,7 @@ public class P2PNetworkSetup {
// We want to get early connected to the price relay so we call it already now
priceFeedService.setCurrencyCodeOnInit();
priceFeedService.initialRequestPriceFeed();
priceFeedService.requestPrices();
}
@Override

View file

@ -137,7 +137,7 @@ public class PriceFeedService {
}
}
public void initialRequestPriceFeed() {
public void requestPrices() {
request(false);
}
@ -145,11 +145,14 @@ public class PriceFeedService {
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.faultHandler = faultHandler;
request(true);
startRequestingPrices();
}
public String getProviderNodeAddress() {

View file

@ -33,7 +33,7 @@ public class MarketPriceFeedServiceTest {
public void testGetPrice() throws InterruptedException {
PriceFeedService priceFeedService = new PriceFeedService(null, null, null);
priceFeedService.setCurrencyCode("EUR");
priceFeedService.requestPriceFeed(tradeCurrency -> {
priceFeedService.startRequestingPrices(tradeCurrency -> {
log.debug(tradeCurrency.toString());
assertTrue(true);
},

View file

@ -132,7 +132,7 @@ public class MarketPricePresentation {
}
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")));
marketPriceBinding = EasyBind.combine(

View file

@ -58,7 +58,7 @@ public class Statistics {
public void onUpdatedDataReceived() {
// we need to have tor ready
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()));
tradeStatisticsManager.onAllServicesInitialized();