From a8fc33c30d4a78058fa62a3577bf22a6d4f26520 Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Sat, 30 Jan 2021 13:08:00 -0500 Subject: [PATCH] On mainNet we expect to have received a filter object, if not show a popup to the user to inform the Bisq devs. Set filterWarningHandler before calling onAllServicesInitialized --- .../main/java/bisq/core/app/DomainInitialisation.java | 2 +- core/src/main/java/bisq/core/filter/FilterManager.java | 9 +++++++++ core/src/main/resources/i18n/displayStrings.properties | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/bisq/core/app/DomainInitialisation.java b/core/src/main/java/bisq/core/app/DomainInitialisation.java index 5843500dd6..489aefc26e 100644 --- a/core/src/main/java/bisq/core/app/DomainInitialisation.java +++ b/core/src/main/java/bisq/core/app/DomainInitialisation.java @@ -242,8 +242,8 @@ public class DomainInitialisation { priceFeedService.setCurrencyCodeOnInit(); - filterManager.onAllServicesInitialized(); filterManager.setFilterWarningHandler(filterWarningHandler); + filterManager.onAllServicesInitialized(); voteResultService.getVoteResultExceptions().addListener((ListChangeListener) c -> { c.next(); diff --git a/core/src/main/java/bisq/core/filter/FilterManager.java b/core/src/main/java/bisq/core/filter/FilterManager.java index 867875196d..163ddbfee3 100644 --- a/core/src/main/java/bisq/core/filter/FilterManager.java +++ b/core/src/main/java/bisq/core/filter/FilterManager.java @@ -103,6 +103,7 @@ public class FilterManager { private final List publicKeys; private ECKey filterSigningKey; private final Set invalidFilters = new HashSet<>(); + private Consumer filterWarningHandler; /////////////////////////////////////////////////////////////////////////////////////////// @@ -152,6 +153,12 @@ public class FilterManager { .map(protectedStoragePayload -> (Filter) protectedStoragePayload) .forEach(this::onFilterAddedFromNetwork); + // On mainNet we expect to have received a filter object, if not show a popup to the user to inform the + // Bisq devs. + if (Config.baseCurrencyNetwork().isMainnet() && getFilter() == null) { + filterWarningHandler.accept(Res.get("popup.warning.noFilter")); + } + p2PService.addHashSetChangedListener(new HashMapChangedListener() { @Override public void onAdded(Collection protectedStorageEntries) { @@ -216,6 +223,8 @@ public class FilterManager { } public void setFilterWarningHandler(Consumer filterWarningHandler) { + this.filterWarningHandler = filterWarningHandler; + addListener(filter -> { if (filter != null && filterWarningHandler != null) { if (filter.getSeedNodes() != null && !filter.getSeedNodes().isEmpty()) { diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 3fb90eea1e..71b038eea0 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2841,6 +2841,7 @@ popup.warning.mandatoryUpdate.dao=Please update to the latest Bisq version. \ Please check out the Bisq Forum for more information. popup.warning.disable.dao=The Bisq DAO and BSQ are temporary disabled. \ Please check out the Bisq Forum for more information. +popup.warning.noFilter=We did not receive a filter object from the seed nodes. This is a not expected situation. Please inform the Bisq developers. popup.warning.burnBTC=This transaction is not possible, as the mining fees of {0} would exceed the amount to transfer of {1}. \ Please wait until the mining fees are low again or until you''ve accumulated more BTC to transfer.