From 09e68fa01fe5d690bb8805022e74dc922d3d7d25 Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Sun, 27 Oct 2019 19:12:57 -0500 Subject: [PATCH 1/2] Check for result phase at activate method Fixes https://github.com/bisq-network/bisq/issues/3487 --- .../main/dao/governance/result/VoteResultView.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java b/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java index f0a10f72f66..7cc6e38f59f 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java @@ -202,6 +202,7 @@ protected void activate() { cyclesTableView.getSelectionModel().selectedItemProperty().addListener(selectedVoteResultListItemListener); if (daoStateService.isParseBlockChainComplete()) { + checkForResultPhase(daoStateService.getChainHeight()); fillCycleList(); } @@ -238,7 +239,11 @@ protected void deactivate() { @Override public void onParseBlockCompleteAfterBatchProcessing(Block block) { - int chainHeight = daoStateService.getChainHeight(); + checkForResultPhase(daoStateService.getChainHeight()); + fillCycleList(); + } + + private void checkForResultPhase(int chainHeight) { if (periodService.getFirstBlockOfPhase(chainHeight, DaoPhase.Phase.RESULT) == chainHeight) { // We had set the cycle initially but at the vote result we want to update it with the actual result. // We remove the empty cycle to make space for the one with the result. @@ -251,8 +256,6 @@ public void onParseBlockCompleteAfterBatchProcessing(Block block) { .findAny(); optionalCurrentCycleListItem.ifPresent(cycleListItemList::remove); } - - fillCycleList(); } From addeae5530bc07fc89fb406053ce33b44ade165b Mon Sep 17 00:00:00 2001 From: sqrrm Date: Mon, 28 Oct 2019 16:02:34 +0100 Subject: [PATCH 2/2] VoteResultView update results on any block in result phase Avoid updating the result more than once per result phase but make sure it's done if activated during the result phase --- .../dao/governance/result/VoteResultView.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java b/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java index 7cc6e38f59f..6370bfde40f 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/governance/result/VoteResultView.java @@ -147,6 +147,7 @@ public class VoteResultView extends ActivatableView implements D private ProposalListItem selectedProposalListItem; private boolean isVoteIncludedInResult; private final Set cyclesAdded = new HashSet<>(); + private boolean hasCalculatedResult = false; /////////////////////////////////////////////////////////////////////////////////////////// @@ -244,17 +245,23 @@ public void onParseBlockCompleteAfterBatchProcessing(Block block) { } private void checkForResultPhase(int chainHeight) { - if (periodService.getFirstBlockOfPhase(chainHeight, DaoPhase.Phase.RESULT) == chainHeight) { - // We had set the cycle initially but at the vote result we want to update it with the actual result. - // We remove the empty cycle to make space for the one with the result. - Optional optionalCurrentCycle = cyclesAdded.stream() - .filter(cycle -> cycle.isInCycle(chainHeight)) - .findAny(); - optionalCurrentCycle.ifPresent(cyclesAdded::remove); - Optional optionalCurrentCycleListItem = cycleListItemList.stream() - .filter(cycleListItem -> cycleListItem.getResultsOfCycle().getCycle().isInCycle(chainHeight)) - .findAny(); - optionalCurrentCycleListItem.ifPresent(cycleListItemList::remove); + if (periodService.isInPhase(chainHeight, DaoPhase.Phase.RESULT)) { + if (!hasCalculatedResult) { + hasCalculatedResult = true; + // We had set the cycle initially but at the vote result we want to update it with the actual result. + // We remove the empty cycle to make space for the one with the result. + Optional optionalCurrentCycle = cyclesAdded.stream() + .filter(cycle -> cycle.isInCycle(chainHeight)) + .findAny(); + optionalCurrentCycle.ifPresent(cyclesAdded::remove); + Optional optionalCurrentCycleListItem = cycleListItemList.stream() + .filter(cycleListItem -> cycleListItem.getResultsOfCycle().getCycle().isInCycle(chainHeight)) + .findAny(); + optionalCurrentCycleListItem.ifPresent(cycleListItemList::remove); + } + } else { + // Reset to be ready to calculate result for next RESULT phase + hasCalculatedResult = false; } }