mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Move 'rpcBlockNotificationHost' option handling to Config
This commit is contained in:
parent
3841e6b1dd
commit
9a7eedb250
7 changed files with 19 additions and 15 deletions
|
@ -69,6 +69,7 @@ public class Config {
|
|||
public static final String RPC_HOST = "rpcHost";
|
||||
public static final String RPC_PORT = "rpcPort";
|
||||
public static final String RPC_BLOCK_NOTIFICATION_PORT = "rpcBlockNotificationPort";
|
||||
public static final String RPC_BLOCK_NOTIFICATION_HOST = "rpcBlockNotificationHost";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Config.class);
|
||||
|
||||
|
@ -135,6 +136,7 @@ public class Config {
|
|||
private final String rpcHost;
|
||||
private final int rpcPort;
|
||||
private final int rpcBlockNotificationPort;
|
||||
private final String rpcBlockNotificationHost;
|
||||
|
||||
// properties derived from cli options, but not exposed as cli options themselves
|
||||
private boolean localBitcoinNodeIsRunning = false; // FIXME: eliminate mutable state
|
||||
|
@ -477,6 +479,12 @@ public class Config {
|
|||
.ofType(int.class)
|
||||
.defaultsTo(UNSPECIFIED_PORT);
|
||||
|
||||
ArgumentAcceptingOptionSpec<String> rpcBlockNotificationHostOpt =
|
||||
parser.accepts(RPC_BLOCK_NOTIFICATION_HOST,
|
||||
"Bitcoind rpc accepted incoming host for block notifications")
|
||||
.withRequiredArg()
|
||||
.defaultsTo("");
|
||||
|
||||
try {
|
||||
OptionSet cliOpts = parser.parse(args);
|
||||
|
||||
|
@ -569,6 +577,7 @@ public class Config {
|
|||
this.rpcHost = options.valueOf(rpcHostOpt);
|
||||
this.rpcPort = options.valueOf(rpcPortOpt);
|
||||
this.rpcBlockNotificationPort = options.valueOf(rpcBlockNotificationPortOpt);
|
||||
this.rpcBlockNotificationHost = options.valueOf(rpcBlockNotificationHostOpt);
|
||||
} catch (OptionException ex) {
|
||||
throw new ConfigException(format("problem parsing option '%s': %s",
|
||||
ex.options().get(0),
|
||||
|
@ -852,4 +861,8 @@ public class Config {
|
|||
public int getRpcBlockNotificationPort() {
|
||||
return rpcBlockNotificationPort;
|
||||
}
|
||||
|
||||
public String getRpcBlockNotificationHost() {
|
||||
return rpcBlockNotificationHost;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package bisq.core.app;
|
|||
import bisq.core.dao.DaoOptionKeys;
|
||||
|
||||
import bisq.common.BisqException;
|
||||
import bisq.common.config.Config;
|
||||
|
||||
import org.springframework.core.env.JOptCommandLinePropertySource;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
|
@ -58,7 +57,7 @@ public class BisqEnvironment extends StandardEnvironment {
|
|||
protected boolean isBitcoinLocalhostNodeRunning;
|
||||
|
||||
protected final String
|
||||
rpcBlockNotificationHost, dumpBlockchainData, fullDaoNode,
|
||||
dumpBlockchainData, fullDaoNode,
|
||||
genesisTxId, genesisBlockHeight, genesisTotalSupply,
|
||||
daoActivated;
|
||||
|
||||
|
@ -70,7 +69,6 @@ public class BisqEnvironment extends StandardEnvironment {
|
|||
@SuppressWarnings("ConstantConditions")
|
||||
public BisqEnvironment(PropertySource commandLineProperties) {
|
||||
//DaoOptionKeys
|
||||
rpcBlockNotificationHost = getProperty(commandLineProperties, DaoOptionKeys.RPC_BLOCK_NOTIFICATION_HOST, "");
|
||||
dumpBlockchainData = getProperty(commandLineProperties, DaoOptionKeys.DUMP_BLOCKCHAIN_DATA, "");
|
||||
fullDaoNode = getProperty(commandLineProperties, DaoOptionKeys.FULL_DAO_NODE, "");
|
||||
genesisTxId = getProperty(commandLineProperties, DaoOptionKeys.GENESIS_TX_ID, "");
|
||||
|
@ -94,7 +92,6 @@ public class BisqEnvironment extends StandardEnvironment {
|
|||
private PropertySource<?> defaultProperties() {
|
||||
return new PropertiesPropertySource(BISQ_DEFAULT_PROPERTY_SOURCE_NAME, new Properties() {
|
||||
{
|
||||
setProperty(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_HOST, rpcBlockNotificationHost);
|
||||
setProperty(DaoOptionKeys.DUMP_BLOCKCHAIN_DATA, dumpBlockchainData);
|
||||
setProperty(DaoOptionKeys.FULL_DAO_NODE, fullDaoNode);
|
||||
setProperty(DaoOptionKeys.GENESIS_TX_ID, genesisTxId);
|
||||
|
|
|
@ -285,10 +285,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
|||
.ofType(boolean.class);
|
||||
|
||||
//RpcOptionKeys
|
||||
parser.accepts(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_HOST,
|
||||
"Bitcoind rpc accepted incoming host for block notifications")
|
||||
.withRequiredArg();
|
||||
|
||||
parser.accepts(DaoOptionKeys.DUMP_BLOCKCHAIN_DATA,
|
||||
format("If set to true the blockchain data from RPC requests to Bitcoin Core are " +
|
||||
"stored as json file in the data dir. (default: %s)", "false"))
|
||||
|
|
|
@ -228,8 +228,7 @@ public class DaoModule extends AppModule {
|
|||
bindConstant().annotatedWith(named(Config.RPC_HOST)).to(config.getRpcHost());
|
||||
bindConstant().annotatedWith(named(Config.RPC_PORT)).to(config.getRpcPort());
|
||||
bindConstant().annotatedWith(named(Config.RPC_BLOCK_NOTIFICATION_PORT)).to(config.getRpcBlockNotificationPort());
|
||||
bindConstant().annotatedWith(named(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_HOST))
|
||||
.to(environment.getRequiredProperty(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_HOST));
|
||||
bindConstant().annotatedWith(named(Config.RPC_BLOCK_NOTIFICATION_HOST)).to(config.getRpcBlockNotificationHost());
|
||||
bindConstant().annotatedWith(named(DaoOptionKeys.DUMP_BLOCKCHAIN_DATA))
|
||||
.to(environment.getRequiredProperty(DaoOptionKeys.DUMP_BLOCKCHAIN_DATA));
|
||||
bindConstant().annotatedWith(named(DaoOptionKeys.FULL_DAO_NODE))
|
||||
|
|
|
@ -21,7 +21,6 @@ package bisq.core.dao;
|
|||
* Provides program argument options used in the DAO domain.
|
||||
*/
|
||||
public class DaoOptionKeys {
|
||||
public static final String RPC_BLOCK_NOTIFICATION_HOST = "rpcBlockNotificationHost";
|
||||
|
||||
public static final String DUMP_BLOCKCHAIN_DATA = "dumpBlockchainData";
|
||||
public static final String FULL_DAO_NODE = "fullDaoNode";
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package bisq.core.dao.node.full;
|
||||
|
||||
import bisq.core.dao.DaoOptionKeys;
|
||||
import bisq.core.dao.state.model.blockchain.PubKeyScript;
|
||||
import bisq.core.dao.state.model.blockchain.TxInput;
|
||||
import bisq.core.user.Preferences;
|
||||
|
@ -96,7 +95,7 @@ public class RpcService {
|
|||
@Named(Config.RPC_HOST) String rpcHost,
|
||||
@Named(Config.RPC_PORT) int rpcPort,
|
||||
@Named(Config.RPC_BLOCK_NOTIFICATION_PORT) int rpcBlockPort,
|
||||
@Named(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_HOST) String rpcBlockHost) {
|
||||
@Named(Config.RPC_BLOCK_NOTIFICATION_HOST) String rpcBlockHost) {
|
||||
this.rpcUser = preferences.getRpcUser();
|
||||
this.rpcPassword = preferences.getRpcPw();
|
||||
|
||||
|
@ -112,7 +111,7 @@ public class RpcService {
|
|||
isTestnet ? 18332 :
|
||||
18443; // regtest
|
||||
boolean isBlockPortSet = rpcBlockPort != Config.UNSPECIFIED_PORT;
|
||||
boolean isBlockHostSet = rpcBlockHost != null && !rpcBlockHost.isEmpty();
|
||||
boolean isBlockHostSet = !rpcBlockHost.isEmpty();
|
||||
this.rpcBlockPort = isBlockPortSet ? rpcBlockPort : 5125;
|
||||
this.rpcBlockHost = isBlockHostSet ? rpcBlockHost : "127.0.0.1";
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import bisq.core.locale.FiatCurrency;
|
|||
import bisq.core.locale.GlobalSettings;
|
||||
import bisq.core.locale.Res;
|
||||
|
||||
import bisq.common.config.Config;
|
||||
import bisq.common.config.TestConfig;
|
||||
import bisq.common.storage.Storage;
|
||||
|
||||
|
@ -58,7 +59,7 @@ public class PreferencesTest {
|
|||
Res.setBaseCurrencyName("Bitcoin");
|
||||
|
||||
storage = mock(Storage.class);
|
||||
preferences = new Preferences(storage, new TestConfig(), null, null, null, null, null, null);
|
||||
preferences = new Preferences(storage, new TestConfig(), null, null, null, null, null, Config.UNSPECIFIED_PORT);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Reference in a new issue