Add useFullModeDaoMonitor to options

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2024-06-29 14:22:00 +07:00
parent 5a8c3bc5bf
commit fd17a29361
No known key found for this signature in database
GPG Key ID: 02AA2BAE387C8307
3 changed files with 33 additions and 4 deletions

View File

@ -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<Boolean> 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),

View File

@ -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);
}
}

View File

@ -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();
}
}