From 87261eca040aca0ebcf4abb66c6361fe7abdc616 Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Wed, 2 Jun 2021 17:45:10 -0500 Subject: [PATCH] warn user when DAO needs resync --- core/src/main/java/bisq/core/dao/DaoFacade.java | 7 +++++++ .../main/resources/i18n/displayStrings.properties | 2 ++ .../desktop/main/presentation/DaoPresentation.java | 11 +++++++++++ desktop/src/main/java/bisq/desktop/util/GUIUtil.java | 12 ++++++++++++ 4 files changed, 32 insertions(+) diff --git a/core/src/main/java/bisq/core/dao/DaoFacade.java b/core/src/main/java/bisq/core/dao/DaoFacade.java index 701849b48ba..8adfe466a26 100644 --- a/core/src/main/java/bisq/core/dao/DaoFacade.java +++ b/core/src/main/java/bisq/core/dao/DaoFacade.java @@ -52,6 +52,7 @@ import bisq.core.dao.governance.proposal.reimbursement.ReimbursementProposalFactory; import bisq.core.dao.governance.proposal.removeAsset.RemoveAssetProposalFactory; import bisq.core.dao.governance.proposal.role.RoleProposalFactory; +import bisq.core.dao.monitoring.DaoStateMonitoringService; import bisq.core.dao.state.DaoStateListener; import bisq.core.dao.state.DaoStateService; import bisq.core.dao.state.model.blockchain.BaseTx; @@ -124,6 +125,7 @@ public class DaoFacade implements DaoSetupService { private final BallotListPresentation ballotListPresentation; private final MyProposalListService myProposalListService; private final DaoStateService daoStateService; + private final DaoStateMonitoringService daoStateMonitoringService; private final PeriodService periodService; private final MyBlindVoteListService myBlindVoteListService; private final MyVoteListService myVoteListService; @@ -150,6 +152,7 @@ public DaoFacade(MyProposalListService myProposalListService, BallotListService ballotListService, BallotListPresentation ballotListPresentation, DaoStateService daoStateService, + DaoStateMonitoringService daoStateMonitoringService, PeriodService periodService, MyBlindVoteListService myBlindVoteListService, MyVoteListService myVoteListService, @@ -172,6 +175,7 @@ public DaoFacade(MyProposalListService myProposalListService, this.ballotListPresentation = ballotListPresentation; this.myProposalListService = myProposalListService; this.daoStateService = daoStateService; + this.daoStateMonitoringService = daoStateMonitoringService; this.periodService = periodService; this.myBlindVoteListService = myBlindVoteListService; this.myVoteListService = myVoteListService; @@ -522,6 +526,9 @@ public Optional getBlockAtHeight(int chainHeight) { return daoStateService.getBlockAtHeight(chainHeight); } + public boolean isInConflictWithSeedNode() { + return daoStateMonitoringService.isInConflictWithSeedNode(); + } /////////////////////////////////////////////////////////////////////////////////////////// // Use case: Bonding diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index b1c83ed06e9..4f73b1856e9 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2848,6 +2848,7 @@ popup.warning.notSufficientConnectionsToBtcNetwork=You need to wait until you ha popup.warning.downloadNotComplete=You need to wait until the download of missing Bitcoin blocks is complete. popup.warning.chainNotSynced=The Bisq wallet blockchain height is not synced correctly. If you recently started the application, please wait until one Bitcoin block has been published.\n\n\ You can check the blockchain height in Settings/Network Info. If more than one block passes and this problem persists it may be stalled, in which case you should do an SPV resync. [HYPERLINK:https://bisq.wiki/Resyncing_SPV_file] +popup.warning.daoNeedsResync=Your Bisq DAO state needs to be resynced.\n\nPlease navigate to DAO Network Monitor menu and follow the prompts to resync the DAO state. popup.warning.removeOffer=Are you sure you want to remove that offer?\nThe maker fee of {0} will be lost if you remove that offer. popup.warning.tooLargePercentageValue=You cannot set a percentage of 100% or larger. popup.warning.examplePercentageValue=Please enter a percentage number like \"5.4\" for 5.4% @@ -3121,6 +3122,7 @@ navigation.settings.preferences=\"Settings/Preferences\" navigation.funds.transactions=\"Funds/Transactions\" navigation.support=\"Support\" navigation.dao.wallet.receive=\"DAO/BSQ Wallet/Receive\" +navigation.dao.networkMonitor=\"DAO Network Monitor\" #################################################################### diff --git a/desktop/src/main/java/bisq/desktop/main/presentation/DaoPresentation.java b/desktop/src/main/java/bisq/desktop/main/presentation/DaoPresentation.java index 27a7eab5d08..27e2be22133 100644 --- a/desktop/src/main/java/bisq/desktop/main/presentation/DaoPresentation.java +++ b/desktop/src/main/java/bisq/desktop/main/presentation/DaoPresentation.java @@ -1,5 +1,8 @@ package bisq.desktop.main.presentation; +import bisq.desktop.Navigation; +import bisq.desktop.util.GUIUtil; + import bisq.core.btc.wallet.BsqWalletService; import bisq.core.btc.wallet.BtcWalletService; import bisq.core.dao.DaoFacade; @@ -32,6 +35,7 @@ public class DaoPresentation implements DaoStateListener { public static final String DAO_NEWS = "daoNewsVersion1.0.0"; private final Preferences preferences; + private final Navigation navigation; private final BtcWalletService btcWalletService; private final DaoFacade daoFacade; private final BsqWalletService bsqWalletService; @@ -44,14 +48,17 @@ public class DaoPresentation implements DaoStateListener { @Getter private final StringProperty bsqInfo = new SimpleStringProperty(""); private final SimpleBooleanProperty showNotification = new SimpleBooleanProperty(false); + private boolean daoConflictWarningShown = false; // allow only one conflict warning per session @Inject public DaoPresentation(Preferences preferences, + Navigation navigation, BtcWalletService btcWalletService, BsqWalletService bsqWalletService, DaoStateService daoStateService, DaoFacade daoFacade) { this.preferences = preferences; + this.navigation = navigation; this.btcWalletService = btcWalletService; this.bsqWalletService = bsqWalletService; this.daoFacade = daoFacade; @@ -91,6 +98,10 @@ private void onUpdateAnyChainHeight() { if (synced) { bsqInfo.set(""); + if (daoFacade.isInConflictWithSeedNode() && !daoConflictWarningShown) { + daoConflictWarningShown = true; // only warn max 1 time per session so as not to annoy + GUIUtil.showDaoNeedsResyncPopup(navigation); + } } else { bsqInfo.set(Res.get("mainView.footer.bsqInfo.synchronizing")); } diff --git a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java index 8f4beb8c122..087d76a0f59 100644 --- a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java @@ -26,6 +26,9 @@ import bisq.desktop.main.MainView; import bisq.desktop.main.account.AccountView; import bisq.desktop.main.account.content.fiataccounts.FiatAccountsView; +import bisq.desktop.main.dao.DaoView; +import bisq.desktop.main.dao.monitor.MonitorView; +import bisq.desktop.main.dao.monitor.daostate.DaoStateMonitorView; import bisq.desktop.main.overlays.popups.Popup; import bisq.core.account.witness.AccountAgeWitness; @@ -757,6 +760,15 @@ public static boolean isBootstrappedOrShowPopup(P2PService p2PService) { return true; } + public static void showDaoNeedsResyncPopup(Navigation navigation) { + UserThread.runAfter(() -> new Popup().warning(Res.get("popup.warning.daoNeedsResync")) + .actionButtonTextWithGoTo("navigation.dao.networkMonitor") + .onAction(() -> { + navigation.navigateTo(MainView.class, DaoView.class, MonitorView.class, DaoStateMonitorView.class); + }) + .show(), 5, TimeUnit.SECONDS); + } + public static boolean isReadyForTxBroadcastOrShowPopup(P2PService p2PService, WalletsSetup walletsSetup) { if (!GUIUtil.isBootstrappedOrShowPopup(p2PService)) { return false;