mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Move 'btcNodes' option handling to Config
This commit is contained in:
parent
4fb60a33ac
commit
5271d4d574
@ -59,6 +59,7 @@ public class Config {
|
||||
public static final String TOR_CONTROL_USE_SAFE_COOKIE_AUTH = "torControlUseSafeCookieAuth";
|
||||
public static final String TOR_STREAM_ISOLATION = "torStreamIsolation";
|
||||
public static final String IGNORE_LOCAL_BTC_NODE = "ignoreLocalBtcNode";
|
||||
public static final String BTC_NODES = "btcNodes";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Config.class);
|
||||
|
||||
@ -112,6 +113,7 @@ public class Config {
|
||||
private final int msgThrottlePer10Sec;
|
||||
private final int sendMsgThrottleTrigger;
|
||||
private final int sendMsgThrottleSleep;
|
||||
private final String btcNodes;
|
||||
|
||||
// properties derived from cli options, but not exposed as cli options themselves
|
||||
private boolean localBitcoinNodeIsRunning = false; // FIXME: eliminate mutable state
|
||||
@ -387,6 +389,12 @@ public class Config {
|
||||
.withRequiredArg()
|
||||
.ofType(int.class)
|
||||
.defaultsTo(50); // Pause in ms to sleep if we get too many messages to send
|
||||
|
||||
ArgumentAcceptingOptionSpec<String> btcNodesOpt =
|
||||
parser.accepts(BTC_NODES, "Custom nodes used for BitcoinJ as comma separated IP addresses.")
|
||||
.withRequiredArg()
|
||||
.describedAs("ip[,...]")
|
||||
.defaultsTo("");
|
||||
try {
|
||||
OptionSet cliOpts = parser.parse(args);
|
||||
|
||||
@ -467,6 +475,7 @@ public class Config {
|
||||
" msgThrottlePerSec={},\n msgThrottlePer10Sec={},\n" +
|
||||
" sendMsgThrottleTrigger={},\n sendMsgThrottleSleep={}\n}",
|
||||
msgThrottlePerSec, msgThrottlePer10Sec, sendMsgThrottleTrigger, sendMsgThrottleSleep);
|
||||
this.btcNodes = options.valueOf(btcNodesOpt);
|
||||
} catch (OptionException ex) {
|
||||
throw new ConfigException(format("problem parsing option '%s': %s",
|
||||
ex.options().get(0),
|
||||
@ -702,4 +711,8 @@ public class Config {
|
||||
public int getSendMsgThrottleSleep() {
|
||||
return sendMsgThrottleSleep;
|
||||
}
|
||||
|
||||
public String getBtcNodes() {
|
||||
return btcNodes;
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
@Setter
|
||||
protected boolean isBitcoinLocalhostNodeRunning;
|
||||
|
||||
protected final String btcNodes, useTorForBtc, rpcUser, rpcPassword,
|
||||
protected final String useTorForBtc, rpcUser, rpcPassword,
|
||||
rpcHost, rpcPort, rpcBlockNotificationPort, rpcBlockNotificationHost, dumpBlockchainData, fullDaoNode,
|
||||
useAllProvidedNodes, numConnectionForBtc, genesisTxId, genesisBlockHeight, genesisTotalSupply,
|
||||
daoActivated;
|
||||
@ -86,7 +86,6 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
daoActivated = getProperty(commandLineProperties, DaoOptionKeys.DAO_ACTIVATED, "true");
|
||||
|
||||
//BtcOptionKeys
|
||||
btcNodes = getProperty(commandLineProperties, BtcOptionKeys.BTC_NODES, "");
|
||||
useTorForBtc = getProperty(commandLineProperties, BtcOptionKeys.USE_TOR_FOR_BTC, "");
|
||||
userAgent = getProperty(commandLineProperties, BtcOptionKeys.USER_AGENT, "Bisq");
|
||||
useAllProvidedNodes = getProperty(commandLineProperties, BtcOptionKeys.USE_ALL_PROVIDED_NODES, "false");
|
||||
@ -121,7 +120,6 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
setProperty(DaoOptionKeys.GENESIS_TOTAL_SUPPLY, genesisTotalSupply);
|
||||
setProperty(DaoOptionKeys.DAO_ACTIVATED, daoActivated);
|
||||
|
||||
setProperty(BtcOptionKeys.BTC_NODES, btcNodes);
|
||||
setProperty(BtcOptionKeys.USE_TOR_FOR_BTC, useTorForBtc);
|
||||
setProperty(BtcOptionKeys.USER_AGENT, userAgent);
|
||||
setProperty(BtcOptionKeys.USE_ALL_PROVIDED_NODES, useAllProvidedNodes);
|
||||
|
@ -286,11 +286,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
||||
.ofType(boolean.class);
|
||||
|
||||
//BtcOptionKeys
|
||||
parser.accepts(BtcOptionKeys.BTC_NODES,
|
||||
"Custom nodes used for BitcoinJ as comma separated IP addresses.")
|
||||
.withRequiredArg()
|
||||
.describedAs("ip[,...]");
|
||||
|
||||
parser.accepts(BtcOptionKeys.USE_TOR_FOR_BTC,
|
||||
"If set to true BitcoinJ is routed over tor (socks 5 proxy).")
|
||||
.withRequiredArg();
|
||||
|
@ -80,7 +80,7 @@ public class BitcoinModule extends AppModule {
|
||||
|
||||
bind(File.class).annotatedWith(named(WALLET_DIR)).toInstance(config.getWalletDir());
|
||||
|
||||
bindConstant().annotatedWith(named(BtcOptionKeys.BTC_NODES)).to(environment.getRequiredProperty(BtcOptionKeys.BTC_NODES));
|
||||
bindConstant().annotatedWith(named(Config.BTC_NODES)).to(config.getBtcNodes());
|
||||
bindConstant().annotatedWith(named(BtcOptionKeys.USER_AGENT)).to(environment.getRequiredProperty(BtcOptionKeys.USER_AGENT));
|
||||
bindConstant().annotatedWith(named(BtcOptionKeys.NUM_CONNECTIONS_FOR_BTC)).to(environment.getRequiredProperty(BtcOptionKeys.NUM_CONNECTIONS_FOR_BTC));
|
||||
bindConstant().annotatedWith(named(BtcOptionKeys.USE_ALL_PROVIDED_NODES)).to(environment.getRequiredProperty(BtcOptionKeys.USE_ALL_PROVIDED_NODES));
|
||||
|
@ -18,7 +18,6 @@
|
||||
package bisq.core.btc;
|
||||
|
||||
public class BtcOptionKeys {
|
||||
public static final String BTC_NODES = "btcNodes";
|
||||
public static final String USE_TOR_FOR_BTC = "useTorForBtc";
|
||||
public static final String SOCKS5_DISCOVER_MODE = "socks5DiscoverMode";
|
||||
public static final String USER_AGENT = "userAgent";
|
||||
|
@ -150,7 +150,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
||||
@Inject
|
||||
public Preferences(Storage<PreferencesPayload> storage,
|
||||
Config config,
|
||||
@Named(BtcOptionKeys.BTC_NODES) String btcNodesFromOptions,
|
||||
@Named(Config.BTC_NODES) String btcNodesFromOptions,
|
||||
@Named(BtcOptionKeys.USE_TOR_FOR_BTC) String useTorFlagFromOptions,
|
||||
@Named(Config.REFERRAL_ID) String referralId,
|
||||
@Named(DaoOptionKeys.FULL_DAO_NODE) String fullDaoNode,
|
||||
|
Loading…
Reference in New Issue
Block a user