Refactor baseCurrencyNetwork field to getter access

This commit is contained in:
Alva Swanson 2025-01-09 20:20:37 +00:00
parent f079e26e09
commit ba333f225c
No known key found for this signature in database
GPG Key ID: 004760E77F753090
15 changed files with 19 additions and 17 deletions

View File

@ -75,7 +75,7 @@ public class SimpleHttpServer {
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";

View File

@ -57,7 +57,7 @@ public class ProxySetup {
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();
}

View File

@ -29,6 +29,7 @@ import java.util.Optional;
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;
@ -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;

View File

@ -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();

View File

@ -82,8 +82,8 @@ class CoreDisputeAgentsService {
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");

View File

@ -380,7 +380,7 @@ public class BisqSetup {
}
private void readMapsFromResources(Runnable completeHandler) {
String postFix = "_" + config.baseCurrencyNetwork.name();
String postFix = "_" + config.getBaseCurrencyNetwork().name();
p2PService.getP2PDataStorage().readFromResources(postFix, completeHandler);
}

View File

@ -284,6 +284,6 @@ public class WalletAppSetup {
postFix = " " + Res.get("mainView.footer.usingTor");
else
postFix = "";
return Res.get(config.baseCurrencyNetwork.name()) + postFix;
return Res.get(config.getBaseCurrencyNetwork().name()) + postFix;
}
}

View File

@ -33,7 +33,7 @@ public abstract class AppSetup {
// 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();
}

View File

@ -93,7 +93,7 @@ public class AppSetupWithP2P extends AppSetup {
@Override
protected void initBasicServices() {
String postFix = "_" + config.baseCurrencyNetwork.name();
String postFix = "_" + config.getBaseCurrencyNetwork().name();
p2PDataStorage.readFromResources(postFix, this::startInitP2PNetwork);
}

View File

@ -57,9 +57,9 @@ public class BitcoinModule extends AppModule {
// 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;
}

View File

@ -51,7 +51,7 @@ public class LocalBitcoinNode {
* 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

View File

@ -172,7 +172,7 @@ public class WalletsSetup {
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);
}

View File

@ -133,7 +133,7 @@ public class DaoStateSnapshotService implements DaoSetupService, DaoStateListene
@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

View File

@ -71,7 +71,7 @@ public class DefaultSeedNodeRepository implements SeedNodeRepository {
}
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()

View File

@ -90,7 +90,7 @@ public class PriceFeedNodeAddressProvider {
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 = "";