Skip to content

Commit

Permalink
Refactor baseCurrencyNetwork field to getter access
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Jan 9, 2025
1 parent f079e26 commit ba333f2
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public SimpleHttpServer(Config config, PeerConncetionModel peerConncetionModel)
started = new Date().toString();
providedBtcNodes = peerConncetionModel.getProvidedBtcNodes();

BaseCurrencyNetwork network = config.baseCurrencyNetwork;
BaseCurrencyNetwork network = config.getBaseCurrencyNetwork();
if (config.useTorForBtcMonitor) {
port = network.isMainnet() ? 8000 : 8001;
networkInfo = network.isMainnet() ? "TOR/MAIN_NET" : "TOR/REG_TEST";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ProxySetup(Config config) {
socksProxyFactory = new SocksProxyFactory("127.0.0.1");
Socks5ProxyProvider socks5ProxyProvider = new Socks5ProxyProvider("", "");
socks5ProxyProvider.setSocks5ProxyInternal(socksProxyFactory);
String networkDirName = config.baseCurrencyNetwork.name().toLowerCase();
String networkDirName = config.getBaseCurrencyNetwork().name().toLowerCase();
torDir = Paths.get(config.appDataDir.getPath(), networkDirName, "tor").toFile();
}

Expand Down
4 changes: 3 additions & 1 deletion common/src/main/java/bisq/common/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import ch.qos.logback.classic.Level;

import lombok.Getter;
import lombok.Setter;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;
Expand Down Expand Up @@ -178,7 +179,8 @@ public class Config {
public final List<String> bannedPriceRelayNodes;
public final List<String> bannedSeedNodes;
public final List<String> filterProvidedSeedNodes;
public final BaseCurrencyNetwork baseCurrencyNetwork;
@Getter
private final BaseCurrencyNetwork baseCurrencyNetwork;
public final NetworkParameters networkParameters;
public final boolean ignoreLocalBtcNode;
public final String bitcoinRegtestHost;
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/bisq/common/setup/CommonSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class CommonSetup {
public static void setup(Config config, GracefulShutDownHandler gracefulShutDownHandler) {
setupLog(config);
AsciiLogo.showAsciiLogo();
Version.setBaseCryptoNetworkId(config.baseCurrencyNetwork.ordinal());
Version.setBaseCryptoNetworkId(config.getBaseCurrencyNetwork().ordinal());
Version.printVersion();
maybePrintPathOfCodeSource();
Profiler.printSystemLoad();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ void registerDisputeAgent(String disputeAgentType, String registrationKey) {
if (!p2PService.isBootstrapped())
throw new NotAvailableException("p2p service is not bootstrapped yet");

if (config.baseCurrencyNetwork.isMainnet()
|| config.baseCurrencyNetwork.isDaoBetaNet()
if (config.getBaseCurrencyNetwork().isMainnet()
|| config.getBaseCurrencyNetwork().isDaoBetaNet()
|| !config.useLocalhostForP2P)
throw new UnsupportedOperationException("dispute agents must be registered in a Bisq UI");

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/bisq/core/app/BisqSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private void maybeShowTac(Runnable nextStep) {
}

private void readMapsFromResources(Runnable completeHandler) {
String postFix = "_" + config.baseCurrencyNetwork.name();
String postFix = "_" + config.getBaseCurrencyNetwork().name();
p2PService.getP2PDataStorage().readFromResources(postFix, completeHandler);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/bisq/core/app/WalletAppSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,6 @@ else if (preferences.getUseTorForBitcoinJ())
postFix = " " + Res.get("mainView.footer.usingTor");
else
postFix = "";
return Res.get(config.baseCurrencyNetwork.name()) + postFix;
return Res.get(config.getBaseCurrencyNetwork().name()) + postFix;
}
}
2 changes: 1 addition & 1 deletion core/src/main/java/bisq/core/app/misc/AppSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public AppSetup(Config config) {
// we need to reference it so the seed node stores tradeStatistics
this.config = config;

Version.setBaseCryptoNetworkId(this.config.baseCurrencyNetwork.ordinal());
Version.setBaseCryptoNetworkId(this.config.getBaseCurrencyNetwork().ordinal());
Version.printVersion();
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/bisq/core/app/misc/AppSetupWithP2P.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void initPersistedDataHosts() {

@Override
protected void initBasicServices() {
String postFix = "_" + config.baseCurrencyNetwork.name();
String postFix = "_" + config.getBaseCurrencyNetwork().name();
p2PDataStorage.readFromResources(postFix, this::startInitP2PNetwork);
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/btc/BitcoinModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ protected void configure() {
// otherwise the specified host or default (localhost)
String regTestHost = config.bitcoinRegtestHost;
if (regTestHost.isEmpty()) {
regTestHost = config.baseCurrencyNetwork.isDaoTestNet() ?
regTestHost = config.getBaseCurrencyNetwork().isDaoTestNet() ?
"104.248.31.39" :
config.baseCurrencyNetwork.isDaoRegTest() ?
config.getBaseCurrencyNetwork().isDaoRegTest() ?
"134.209.242.206" :
Config.DEFAULT_REGTEST_HOST;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public boolean shouldBeUsed() {
* Returns whether Bisq should ignore a local Bitcoin node even if it is usable.
*/
public boolean shouldBeIgnored() {
BaseCurrencyNetwork baseCurrencyNetwork = config.baseCurrencyNetwork;
BaseCurrencyNetwork baseCurrencyNetwork = config.getBaseCurrencyNetwork();

// For dao testnet (server side regtest) we disable the use of local bitcoin node
// to avoid confusion if local btc node is not synced with our dao testnet master
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/bisq/core/btc/setup/WalletsSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public WalletsSetup(RegTestHost regTestHost,
this.socks5DiscoverMode = evaluateMode(socks5DiscoverModeString);
this.walletDir = walletDir;

btcWalletFileName = "bisq_" + config.baseCurrencyNetwork.getCurrencyCode() + ".wallet";
btcWalletFileName = "bisq_" + config.getBaseCurrencyNetwork().getCurrencyCode() + ".wallet";
params = Config.baseCurrencyNetworkParameters();
PeerGroup.setIgnoreHttpSeeds(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void shutDown() {

@Override
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
if (config.baseCurrencyNetwork.isMainnet() &&
if (config.getBaseCurrencyNetwork().isMainnet() &&
walletsSetup.isDownloadComplete() &&
daoStateService.getChainHeight() == bsqWalletService.getBestChainHeight()) {
// In case the DAO state is invalid we might get an outdated RECIPIENT_BTC_ADDRESS. In that case we trigger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void reload() {
}

cache.clear();
List<NodeAddress> result = getSeedNodeAddressesFromPropertyFile(config.baseCurrencyNetwork.name().toLowerCase(Locale.ENGLISH));
List<NodeAddress> result = getSeedNodeAddressesFromPropertyFile(config.getBaseCurrencyNetwork().name().toLowerCase(Locale.ENGLISH));
cache.addAll(result);

Set<NodeAddress> filterProvidedSeedNodes = config.filterProvidedSeedNodes.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void selectNextProviderBaseUrl() {
baseUrl = providerList.get(index);
index++;

if (providerList.size() == 1 && config.baseCurrencyNetwork.isMainnet())
if (providerList.size() == 1 && config.getBaseCurrencyNetwork().isMainnet())
log.warn("We only have one provider");
} else {
baseUrl = "";
Expand Down

0 comments on commit ba333f2

Please sign in to comment.