mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Move 'providers' option handling to Config
This option should be renamed to 'priceNodes' or similar, but is out of scope here.
This commit is contained in:
parent
051c53278e
commit
a720475871
@ -37,6 +37,7 @@ public class Config {
|
||||
public static final String USE_DEV_PRIVILEGE_KEYS = "useDevPrivilegeKeys";
|
||||
public static final String DUMP_STATISTICS = "dumpStatistics";
|
||||
public static final String IGNORE_DEV_MSG = "ignoreDevMsg";
|
||||
public static final String PROVIDERS = "providers";
|
||||
|
||||
static final String DEFAULT_CONFIG_FILE_NAME = "bisq.properties";
|
||||
static final int DEFAULT_NODE_PORT = 9999;
|
||||
@ -71,6 +72,7 @@ public class Config {
|
||||
private final boolean dumpStatistics;
|
||||
private final int maxMemory;
|
||||
private final boolean ignoreDevMsg;
|
||||
private final List<String> providers;
|
||||
|
||||
// properties derived from cli options, but not exposed as cli options themselves
|
||||
private boolean localBitcoinNodeIsRunning = false; // FIXME: eliminate mutable state
|
||||
@ -235,6 +237,12 @@ public class Config {
|
||||
.withRequiredArg()
|
||||
.ofType(boolean.class)
|
||||
.defaultsTo(false);
|
||||
|
||||
ArgumentAcceptingOptionSpec<String> providersOpt =
|
||||
parser.accepts(PROVIDERS, "List custom providers")
|
||||
.withRequiredArg()
|
||||
.withValuesSeparatedBy(',')
|
||||
.describedAs("host:port[,...]");
|
||||
try {
|
||||
OptionSet cliOpts = parser.parse(args);
|
||||
|
||||
@ -292,6 +300,7 @@ public class Config {
|
||||
this.dumpStatistics = options.valueOf(dumpStatisticsOpt);
|
||||
this.maxMemory = options.valueOf(maxMemoryOpt);
|
||||
this.ignoreDevMsg = options.valueOf(ignoreDevMsgOpt);
|
||||
this.providers = options.valuesOf(providersOpt);
|
||||
} catch (OptionException ex) {
|
||||
throw new ConfigException(format("problem parsing option '%s': %s",
|
||||
ex.options().get(0),
|
||||
@ -459,4 +468,8 @@ public class Config {
|
||||
public boolean isIgnoreDevMsg() {
|
||||
return ignoreDevMsg;
|
||||
}
|
||||
|
||||
public List<String> getProviders() {
|
||||
return providers;
|
||||
}
|
||||
}
|
||||
|
@ -18,5 +18,4 @@
|
||||
package bisq.core.app;
|
||||
|
||||
public class AppOptionKeys {
|
||||
public static final String PROVIDERS = "providers";
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import bisq.network.p2p.network.ConnectionConfig;
|
||||
import bisq.common.BisqException;
|
||||
import bisq.common.CommonOptionKeys;
|
||||
import bisq.common.config.BaseCurrencyNetwork;
|
||||
import bisq.common.config.Config;
|
||||
|
||||
import org.springframework.core.env.JOptCommandLinePropertySource;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
@ -64,7 +65,7 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
|
||||
@Getter
|
||||
protected final String userAgent;
|
||||
protected final String logLevel, providers;
|
||||
protected final String logLevel;
|
||||
@Getter
|
||||
@Setter
|
||||
protected boolean isBitcoinLocalhostNodeRunning;
|
||||
@ -92,7 +93,6 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
logLevel = getProperty(commandLineProperties, CommonOptionKeys.LOG_LEVEL_KEY, LOG_LEVEL_DEFAULT);
|
||||
|
||||
//AppOptionKeys
|
||||
providers = getProperty(commandLineProperties, AppOptionKeys.PROVIDERS, "");
|
||||
|
||||
//NetworkOptionKeys
|
||||
seedNodes = getProperty(commandLineProperties, NetworkOptionKeys.SEED_NODES_KEY, "");
|
||||
@ -174,8 +174,6 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
setProperty(NetworkOptionKeys.SEND_MSG_THROTTLE_TRIGGER, sendMsgThrottleTrigger);
|
||||
setProperty(NetworkOptionKeys.SEND_MSG_THROTTLE_SLEEP, sendMsgThrottleSleep);
|
||||
|
||||
setProperty(AppOptionKeys.PROVIDERS, providers);
|
||||
|
||||
setProperty(DaoOptionKeys.RPC_USER, rpcUser);
|
||||
setProperty(DaoOptionKeys.RPC_PASSWORD, rpcPassword);
|
||||
setProperty(DaoOptionKeys.RPC_HOST, rpcHost);
|
||||
|
@ -397,11 +397,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
||||
.withRequiredArg()
|
||||
.ofType(boolean.class);
|
||||
|
||||
parser.accepts(AppOptionKeys.PROVIDERS,
|
||||
"Custom providers (comma separated)")
|
||||
.withRequiredArg()
|
||||
.describedAs("host:port[,...]");
|
||||
|
||||
//BtcOptionKeys
|
||||
parser.accepts(BtcOptionKeys.REG_TEST_HOST,
|
||||
format("Bitcoin regtest host when using BTC_REGTEST network (default: %s)", RegTestHost.DEFAULT_HOST))
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
package bisq.core.btc;
|
||||
|
||||
import bisq.core.app.AppOptionKeys;
|
||||
import bisq.core.btc.model.AddressEntryList;
|
||||
import bisq.core.btc.nodes.BtcNodes;
|
||||
import bisq.core.btc.setup.RegTestHost;
|
||||
@ -39,12 +38,15 @@ import bisq.common.config.Config;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static bisq.common.config.Config.PROVIDERS;
|
||||
import static bisq.common.config.Config.WALLET_DIR;
|
||||
import static com.google.inject.name.Names.named;
|
||||
|
||||
@ -86,7 +88,7 @@ public class BitcoinModule extends AppModule {
|
||||
bindConstant().annotatedWith(named(BtcOptionKeys.IGNORE_LOCAL_BTC_NODE)).to(environment.getRequiredProperty(BtcOptionKeys.IGNORE_LOCAL_BTC_NODE));
|
||||
String socks5DiscoverMode = environment.getProperty(BtcOptionKeys.SOCKS5_DISCOVER_MODE, String.class, "ALL");
|
||||
bind(String.class).annotatedWith(Names.named(BtcOptionKeys.SOCKS5_DISCOVER_MODE)).toInstance(socks5DiscoverMode);
|
||||
bindConstant().annotatedWith(named(AppOptionKeys.PROVIDERS)).to(environment.getRequiredProperty(AppOptionKeys.PROVIDERS));
|
||||
bind(new TypeLiteral<List<String>>(){}).annotatedWith(named(PROVIDERS)).toInstance(config.getProviders());
|
||||
|
||||
bind(AddressEntryList.class).in(Singleton.class);
|
||||
bind(WalletsSetup.class).in(Singleton.class);
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
package bisq.core.provider;
|
||||
|
||||
import bisq.core.app.AppOptionKeys;
|
||||
|
||||
import bisq.network.NetworkOptionKeys;
|
||||
|
||||
import bisq.common.config.Config;
|
||||
@ -27,8 +25,6 @@ import com.google.inject.Inject;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -50,7 +46,7 @@ public class ProvidersRepository {
|
||||
);
|
||||
|
||||
private final Config config;
|
||||
private final String providersFromProgramArgs;
|
||||
private final List<String> providersFromProgramArgs;
|
||||
private final boolean useLocalhostForP2P;
|
||||
|
||||
private List<String> providerList;
|
||||
@ -68,7 +64,7 @@ public class ProvidersRepository {
|
||||
|
||||
@Inject
|
||||
public ProvidersRepository(Config config,
|
||||
@Named(AppOptionKeys.PROVIDERS) String providers,
|
||||
@Named(Config.PROVIDERS) List<String> providers,
|
||||
@Named(NetworkOptionKeys.USE_LOCALHOST_FOR_P2P) boolean useLocalhostForP2P) {
|
||||
|
||||
this.config = config;
|
||||
@ -111,7 +107,7 @@ public class ProvidersRepository {
|
||||
|
||||
private void fillProviderList() {
|
||||
List<String> providers;
|
||||
if (providersFromProgramArgs == null || providersFromProgramArgs.isEmpty()) {
|
||||
if (providersFromProgramArgs.isEmpty()) {
|
||||
if (useLocalhostForP2P) {
|
||||
// If we run in localhost mode we don't have the tor node running, so we need a clearnet host
|
||||
// Use localhost for using a locally running provider
|
||||
@ -121,7 +117,7 @@ public class ProvidersRepository {
|
||||
providers = DEFAULT_NODES;
|
||||
}
|
||||
} else {
|
||||
providers = Arrays.asList(StringUtils.deleteWhitespace(providersFromProgramArgs).split(","));
|
||||
providers = providersFromProgramArgs;
|
||||
}
|
||||
providerList = providers.stream()
|
||||
.filter(e -> bannedNodes == null ||
|
||||
|
Loading…
Reference in New Issue
Block a user