From 2749e7d41a6dfa97959b292a21e0be8a9a1afe39 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Mon, 29 Jul 2024 10:51:00 +0700 Subject: [PATCH] Extract code for removing retired nodes to a methods so its easier to spot Signed-off-by: HenrikJannsen --- .../main/java/bisq/core/user/Preferences.java | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/core/src/main/java/bisq/core/user/Preferences.java b/core/src/main/java/bisq/core/user/Preferences.java index ca64f523ee..ac00e94c65 100644 --- a/core/src/main/java/bisq/core/user/Preferences.java +++ b/core/src/main/java/bisq/core/user/Preferences.java @@ -316,25 +316,7 @@ private void setupPreferences() { useStandbyModeProperty.set(prefPayload.isUseStandbyMode()); cssThemeProperty.set(prefPayload.getCssTheme()); - // a list of previously-used federated explorers - // if user preference references any deprecated explorers we need to select a new valid explorer - String deprecatedExplorers = "(bsq.bisq.cc|bsq.vante.me|bsq.emzy.de|bsq.sqrrm.net|bsq.bisq.services|bsq.ninja|bisq.mempool.emzy.de).*"; - - // if no valid Bitcoin block explorer is set, select the 1st valid Bitcoin block explorer - ArrayList btcExplorers = getBlockChainExplorers(); - if (getBlockChainExplorer() == null || - getBlockChainExplorer().name.length() == 0 || - getBlockChainExplorer().name.matches(deprecatedExplorers)) { - setBlockChainExplorer(btcExplorers.get(0)); - } - - // if no valid BSQ block explorer is set, randomly select a valid BSQ block explorer - ArrayList bsqExplorers = getBsqBlockChainExplorers(); - if (getBsqBlockChainExplorer() == null || - getBsqBlockChainExplorer().name.length() == 0 || - getBsqBlockChainExplorer().name.matches(deprecatedExplorers)) { - setBsqBlockChainExplorer(bsqExplorers.get((new Random()).nextInt(bsqExplorers.size()))); - } + clearRetiredNodes(); tradeCurrenciesAsObservable.addAll(prefPayload.getFiatCurrencies()); tradeCurrenciesAsObservable.addAll(prefPayload.getCryptoCurrencies()); @@ -372,6 +354,35 @@ private void setupPreferences() { setUsePriceNotifications(true); } + // We set the capability in CoreNetworkCapabilities if the program argument is set. + // If we have set it in the preferences view we handle it here. + CoreNetworkCapabilities.maybeApplyDaoFullMode(config); + + initialReadDone = true; + requestPersistence(); + } + + private void clearRetiredNodes() { + // a list of previously-used federated explorers + // if user preference references any deprecated explorers we need to select a new valid explorer + String deprecatedExplorers = "(bsq.bisq.cc|bsq.vante.me|bsq.emzy.de|bsq.sqrrm.net|bsq.bisq.services|bsq.ninja|bisq.mempool.emzy.de).*"; + + // if no valid Bitcoin block explorer is set, select the 1st valid Bitcoin block explorer + ArrayList btcExplorers = getBlockChainExplorers(); + if (getBlockChainExplorer() == null || + getBlockChainExplorer().name.length() == 0 || + getBlockChainExplorer().name.matches(deprecatedExplorers)) { + setBlockChainExplorer(btcExplorers.get(0)); + } + + // if no valid BSQ block explorer is set, randomly select a valid BSQ block explorer + ArrayList bsqExplorers = getBsqBlockChainExplorers(); + if (getBsqBlockChainExplorer() == null || + getBsqBlockChainExplorer().name.length() == 0 || + getBsqBlockChainExplorer().name.matches(deprecatedExplorers)) { + setBsqBlockChainExplorer(bsqExplorers.get((new Random()).nextInt(bsqExplorers.size()))); + } + // Remove retired XMR AutoConfirm address var doApplyDefaults = prefPayload.getAutoConfirmSettingsList().stream() .map(autoConfirmSettings -> autoConfirmSettings.getServiceAddresses().stream() @@ -387,13 +398,6 @@ private void setupPreferences() { }); persistenceManager.forcePersistNow(); } - - // We set the capability in CoreNetworkCapabilities if the program argument is set. - // If we have set it in the preferences view we handle it here. - CoreNetworkCapabilities.maybeApplyDaoFullMode(config); - - initialReadDone = true; - requestPersistence(); }