From da1626070b5eeb1007b37ccfc20d5312af34a99c Mon Sep 17 00:00:00 2001 From: PrinceOfEgypt Date: Sat, 24 Feb 2024 09:36:02 -0600 Subject: [PATCH 1/3] Add 2 second delay to RatesService --- src/main/java/com/sparrowwallet/sparrow/AppServices.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index f35dbb4d..2d7d9bd6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -355,6 +355,8 @@ public class AppServices { ExchangeSource.RatesService ratesService = new ExchangeSource.RatesService( exchangeSource == null ? DEFAULT_EXCHANGE_SOURCE : exchangeSource, currency == null ? DEFAULT_FIAT_CURRENCY : currency); + //Delay startup on first run + ratesService.setDelay(Duration.seconds(CONNECTION_DELAY_SECS)); ratesService.setPeriod(Duration.seconds(RATES_PERIOD_SECS)); ratesService.setRestartOnFailure(true); From 17ea75603f2c7a21ff2d1fa7b8043fc81298062f Mon Sep 17 00:00:00 2001 From: PrinceOfEgypt Date: Sun, 25 Feb 2024 12:14:11 -0600 Subject: [PATCH 2/3] Create separate constant for RatesService delay --- src/main/java/com/sparrowwallet/sparrow/AppServices.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index 2d7d9bd6..ff3fe096 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -78,6 +78,7 @@ public class AppServices { private static final int RATES_PERIOD_SECS = 5 * 60; private static final int VERSION_CHECK_PERIOD_HOURS = 24; private static final int CONNECTION_DELAY_SECS = 2; + private static final int RATES_STARTUP_DELAY_SECS = 5; private static final ExchangeSource DEFAULT_EXCHANGE_SOURCE = ExchangeSource.COINGECKO; private static final Currency DEFAULT_FIAT_CURRENCY = Currency.getInstance("USD"); private static final String TOR_DEFAULT_PROXY_CIRCUIT_ID = "default"; @@ -356,7 +357,7 @@ public class AppServices { exchangeSource == null ? DEFAULT_EXCHANGE_SOURCE : exchangeSource, currency == null ? DEFAULT_FIAT_CURRENCY : currency); //Delay startup on first run - ratesService.setDelay(Duration.seconds(CONNECTION_DELAY_SECS)); + ratesService.setDelay(Duration.seconds(RATES_STARTUP_DELAY_SECS)); ratesService.setPeriod(Duration.seconds(RATES_PERIOD_SECS)); ratesService.setRestartOnFailure(true); From cc9a557a2ef484294ee38ce78fbe7af51e6390d3 Mon Sep 17 00:00:00 2001 From: PrinceOfEgypt Date: Mon, 26 Feb 2024 09:22:17 -0600 Subject: [PATCH 3/3] Configure startup delay by platform --- .../com/sparrowwallet/sparrow/AppServices.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index ff3fe096..9f73c96f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -78,7 +78,8 @@ public class AppServices { private static final int RATES_PERIOD_SECS = 5 * 60; private static final int VERSION_CHECK_PERIOD_HOURS = 24; private static final int CONNECTION_DELAY_SECS = 2; - private static final int RATES_STARTUP_DELAY_SECS = 5; + private static final int RATES_STARTUP_DELAY_SECS_DEFAULT = 2; + private static final int RATES_STARTUP_DELAY_SECS_WINDOWS = 5; private static final ExchangeSource DEFAULT_EXCHANGE_SOURCE = ExchangeSource.COINGECKO; private static final Currency DEFAULT_FIAT_CURRENCY = Currency.getInstance("USD"); private static final String TOR_DEFAULT_PROXY_CIRCUIT_ID = "default"; @@ -357,7 +358,20 @@ public class AppServices { exchangeSource == null ? DEFAULT_EXCHANGE_SOURCE : exchangeSource, currency == null ? DEFAULT_FIAT_CURRENCY : currency); //Delay startup on first run - ratesService.setDelay(Duration.seconds(RATES_STARTUP_DELAY_SECS)); + switch(org.controlsfx.tools.Platform.getCurrent()) + { + case WINDOWS: + //Windows needs more time (5 Seconds) + ratesService.setDelay(Duration.seconds(RATES_STARTUP_DELAY_SECS_WINDOWS)); + break; + case OSX: + case UNIX: + case UNKNOWN: + default: + //Other platforms seem ok with 2 Seconds + ratesService.setDelay(Duration.seconds(RATES_STARTUP_DELAY_SECS_DEFAULT)); + break; + } ratesService.setPeriod(Duration.seconds(RATES_PERIOD_SECS)); ratesService.setRestartOnFailure(true);