From fd17a2936189bf10ba9dcf5986297f0ea2c75179 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Sat, 29 Jun 2024 14:22:00 +0700 Subject: [PATCH] Add useFullModeDaoMonitor to options Signed-off-by: HenrikJannsen --- .../main/java/bisq/common/config/Config.java | 13 +++++++++++ .../main/java/bisq/core/dao/DaoModule.java | 1 + .../main/java/bisq/core/user/Preferences.java | 23 +++++++++++++++---- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/bisq/common/config/Config.java b/common/src/main/java/bisq/common/config/Config.java index fb8040b8ab..1b35f4ce35 100644 --- a/common/src/main/java/bisq/common/config/Config.java +++ b/common/src/main/java/bisq/common/config/Config.java @@ -139,6 +139,7 @@ public class Config { public static final String BM_ORACLE_NODE_PRIV_KEY = "bmOracleNodePrivKey"; public static final String SEED_NODE_REPORTING_SERVER_URL = "seedNodeReportingServerUrl"; public static final String USE_TOR_FOR_BTC_MONITOR = "useTorForBtcMonitor"; + public static final String USE_FULL_MODE_DAO_MONITOR = "useFullModeDaoMonitor"; // Default values for certain options public static final int UNSPECIFIED_PORT = -1; @@ -239,6 +240,8 @@ public class Config { public final String bmOracleNodePrivKey; public final String seedNodeReportingServerUrl; public final boolean useTorForBtcMonitor; + public final boolean useFullModeDaoMonitor; + public final boolean useFullModeDaoMonitorSetExplicitly; // Properties derived from options but not exposed as options themselves public final File torDir; @@ -746,6 +749,14 @@ public class Config { .ofType(Boolean.class) .defaultsTo(true); + ArgumentAcceptingOptionSpec useFullModeDaoMonitorOpt = + parser.accepts(USE_FULL_MODE_DAO_MONITOR, "If set to true full mode DAO monitor is activated. " + + "By that at each block during parsing the dao state hash is created, " + + "otherwise only after block parsing is complete and on new blocks.") + .withRequiredArg() + .ofType(Boolean.class) + .defaultsTo(false); + try { CompositeOptionSet options = new CompositeOptionSet(); @@ -873,6 +884,8 @@ public class Config { this.bmOracleNodePrivKey = options.valueOf(bmOracleNodePrivKey); this.seedNodeReportingServerUrl = options.valueOf(seedNodeReportingServerUrlOpt); this.useTorForBtcMonitor = options.valueOf(useTorForBtcMonitorOpt); + this.useFullModeDaoMonitor = options.valueOf(useFullModeDaoMonitorOpt); + this.useFullModeDaoMonitorSetExplicitly = options.has(useFullModeDaoMonitorOpt); } catch (OptionException ex) { throw new ConfigException("problem parsing option '%s': %s", ex.options().get(0), diff --git a/core/src/main/java/bisq/core/dao/DaoModule.java b/core/src/main/java/bisq/core/dao/DaoModule.java index 3d10caedb8..7d622e512a 100644 --- a/core/src/main/java/bisq/core/dao/DaoModule.java +++ b/core/src/main/java/bisq/core/dao/DaoModule.java @@ -225,6 +225,7 @@ public class DaoModule extends AppModule { bindConstant().annotatedWith(named(Config.IS_BM_FULL_NODE)).to(config.isBmFullNode); bindConstant().annotatedWith(named(Config.BM_ORACLE_NODE_PUB_KEY)).to(config.bmOracleNodePubKey); bindConstant().annotatedWith(named(Config.BM_ORACLE_NODE_PRIV_KEY)).to(config.bmOracleNodePrivKey); + bindConstant().annotatedWith(named(Config.USE_FULL_MODE_DAO_MONITOR)).to(config.useFullModeDaoMonitor); } } diff --git a/core/src/main/java/bisq/core/user/Preferences.java b/core/src/main/java/bisq/core/user/Preferences.java index ab1e58dff2..79f387b368 100644 --- a/core/src/main/java/bisq/core/user/Preferences.java +++ b/core/src/main/java/bisq/core/user/Preferences.java @@ -171,7 +171,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid private final String btcNodesFromOptions, referralIdFromOptions, rpcUserFromOptions, rpcPwFromOptions; private final int blockNotifyPortFromOptions; - private final boolean fullDaoNodeFromOptions, fullAccountingNodeFromOptions; + private final boolean fullDaoNodeFromOptions, fullAccountingNodeFromOptions, useFullModeDaoMonitorFromOptions; @Getter private final BooleanProperty useStandbyModeProperty = new SimpleBooleanProperty(prefPayload.isUseStandbyMode()); @@ -191,7 +191,8 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid @Named(Config.IS_BM_FULL_NODE) boolean fullAccountingNode, @Named(Config.RPC_USER) String rpcUser, @Named(Config.RPC_PASSWORD) String rpcPassword, - @Named(Config.RPC_BLOCK_NOTIFICATION_PORT) int rpcBlockNotificationPort) { + @Named(Config.RPC_BLOCK_NOTIFICATION_PORT) int rpcBlockNotificationPort, + @Named(Config.USE_FULL_MODE_DAO_MONITOR) boolean useFullModeDaoMonitor) { this.persistenceManager = persistenceManager; this.config = config; @@ -204,6 +205,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid this.rpcUserFromOptions = rpcUser; this.rpcPwFromOptions = rpcPassword; this.blockNotifyPortFromOptions = rpcBlockNotificationPort; + this.useFullModeDaoMonitorFromOptions = useFullModeDaoMonitor; useAnimationsProperty.addListener((ov) -> { prefPayload.setUseAnimations(useAnimationsProperty.get()); @@ -828,8 +830,11 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid } public void setUseFullModeDaoMonitor(boolean value) { - prefPayload.setUseFullModeDaoMonitor(value); - requestPersistence(); + // We only persist if we have not set the program argument + if (!config.useFullModeDaoMonitorSetExplicitly) { + prefPayload.setUseFullModeDaoMonitor(value); + requestPersistence(); + } } public void setUseBitcoinUrisInQrCodes(boolean value) { @@ -1031,6 +1036,14 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid return prefPayload.isFullBMAccountingNode(); } + public boolean isUseFullModeDaoMonitor() { + if (config.useFullModeDaoMonitorSetExplicitly) { + return useFullModeDaoMonitorFromOptions; + } else { + return prefPayload.isUseFullModeDaoMonitor(); + } + } + /////////////////////////////////////////////////////////////////////////////////////////// // Private @@ -1202,5 +1215,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid void setProcessBurningManAccountingData(boolean processBurningManAccountingData); void setFullBMAccountingNode(boolean isFullBMAccountingNode); + + boolean isUseFullModeDaoMonitor(); } }