Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to prevent periodic shutdown for seed nodes #5039

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions common/src/main/java/bisq/common/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public class Config {
public static final String ALLOW_FAULTY_DELAYED_TXS = "allowFaultyDelayedTxs";
public static final String API_PASSWORD = "apiPassword";
public static final String API_PORT = "apiPort";
public static final String PREVENT_PERIODIC_SHUTDOWN_AT_SEED_NODE = "preventPeriodicShutdownAtSeedNode";

// Default values for certain options
public static final int UNSPECIFIED_PORT = -1;
Expand Down Expand Up @@ -205,6 +206,7 @@ public class Config {
public final boolean allowFaultyDelayedTxs;
public final String apiPassword;
public final int apiPort;
public final boolean preventPeriodicShutdownAtSeedNode;

// Properties derived from options but not exposed as options themselves
public final File torDir;
Expand Down Expand Up @@ -639,6 +641,13 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) {
.ofType(Integer.class)
.defaultsTo(9998);

ArgumentAcceptingOptionSpec<Boolean> preventPeriodicShutdownAtSeedNodeOpt =
parser.accepts(PREVENT_PERIODIC_SHUTDOWN_AT_SEED_NODE,
"Prevents periodic shutdown at seed nodes")
.withRequiredArg()
.ofType(boolean.class)
.defaultsTo(false);

try {
CompositeOptionSet options = new CompositeOptionSet();

Expand Down Expand Up @@ -754,6 +763,7 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) {
this.allowFaultyDelayedTxs = options.valueOf(allowFaultyDelayedTxsOpt);
this.apiPassword = options.valueOf(apiPasswordOpt);
this.apiPort = options.valueOf(apiPortOpt);
this.preventPeriodicShutdownAtSeedNode = options.valueOf(preventPeriodicShutdownAtSeedNodeOpt);
} catch (OptionException ex) {
throw new ConfigException("problem parsing option '%s': %s",
ex.options().get(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected void configure() {
bindConstant().annotatedWith(named(USE_DEV_MODE)).to(config.useDevMode);
bindConstant().annotatedWith(named(USE_DEV_MODE_HEADER)).to(config.useDevModeHeader);
bindConstant().annotatedWith(named(REFERRAL_ID)).to(config.referralId);
bindConstant().annotatedWith(named(PREVENT_PERIODIC_SHUTDOWN_AT_SEED_NODE)).to(config.preventPeriodicShutdownAtSeedNode);

// ordering is used for shut down sequence
install(new TradeModule(config));
Expand Down
9 changes: 8 additions & 1 deletion seednode/src/main/java/bisq/seednode/SeedNodeMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
import bisq.common.config.Config;
import bisq.common.handlers.ResultHandler;

import com.google.inject.Key;
import com.google.inject.name.Names;

import lombok.extern.slf4j.Slf4j;

@Slf4j
Expand Down Expand Up @@ -139,7 +142,11 @@ public void onTorNodeReady() {

@Override
public void onHiddenServicePublished() {
startShutDownInterval(SeedNodeMain.this);
boolean preventPeriodicShutdownAtSeedNode = injector.getInstance(Key.get(boolean.class,
Names.named(Config.PREVENT_PERIODIC_SHUTDOWN_AT_SEED_NODE)));
if (!preventPeriodicShutdownAtSeedNode) {
startShutDownInterval(SeedNodeMain.this);
}
UserThread.runAfter(() -> setupConnectionLossCheck(), 60);
}

Expand Down