From e0b00513b9017c460654cd31700a1ba7e32de616 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 12 May 2022 14:50:31 +0200 Subject: [PATCH] make usb hw enumerate period configurable --- src/main/java/com/sparrowwallet/sparrow/AppServices.java | 4 ++-- src/main/java/com/sparrowwallet/sparrow/io/Config.java | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index b5e491f3..b5032304 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -70,7 +70,7 @@ public class AppServices { private static final int SERVER_PING_PERIOD_SECS = 60; private static final int PUBLIC_SERVER_RETRY_PERIOD_SECS = 3; - private static final int ENUMERATE_HW_PERIOD_SECS = 30; + public static final int ENUMERATE_HW_PERIOD_SECS = 30; private static final int RATES_PERIOD_SECS = 5 * 60; private static final int VERSION_CHECK_PERIOD_HOURS = 24; private static final ExchangeSource DEFAULT_EXCHANGE_SOURCE = ExchangeSource.COINGECKO; @@ -358,7 +358,7 @@ public class AppServices { private Hwi.ScheduledEnumerateService createDeviceEnumerateService() { Hwi.ScheduledEnumerateService enumerateService = new Hwi.ScheduledEnumerateService(null); - enumerateService.setPeriod(Duration.seconds(ENUMERATE_HW_PERIOD_SECS)); + enumerateService.setPeriod(Duration.seconds(Config.get().getEnumerateHwPeriod())); enumerateService.setOnSucceeded(workerStateEvent -> { List devices = enumerateService.getValue(); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Config.java b/src/main/java/com/sparrowwallet/sparrow/io/Config.java index bee6af5b..728c3a79 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Config.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Config.java @@ -15,6 +15,7 @@ import java.lang.reflect.Type; import java.util.*; import java.util.stream.Collectors; +import static com.sparrowwallet.sparrow.AppServices.ENUMERATE_HW_PERIOD_SECS; import static com.sparrowwallet.sparrow.net.PagedBatchRequestBuilder.DEFAULT_PAGE_SIZE; import static com.sparrowwallet.sparrow.net.TcpTransport.DEFAULT_MAX_TIMEOUT; @@ -45,6 +46,7 @@ public class Config { private List recentWalletFiles; private Integer keyDerivationPeriod; private File hwi; + private int enumerateHwPeriod = ENUMERATE_HW_PERIOD_SECS; private Boolean hdCapture; private String webcamDevice; private ServerType serverType; @@ -309,6 +311,10 @@ public class Config { flush(); } + public int getEnumerateHwPeriod() { + return enumerateHwPeriod; + } + public Boolean getHdCapture() { return hdCapture; }