Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with not updating vote result table at vote result block #3442

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import bisq.core.dao.state.model.governance.CompensationProposal;
import bisq.core.dao.state.model.governance.ConfiscateBondProposal;
import bisq.core.dao.state.model.governance.Cycle;
import bisq.core.dao.state.model.governance.DaoPhase;
import bisq.core.dao.state.model.governance.DecryptedBallotsWithMerits;
import bisq.core.dao.state.model.governance.EvaluatedProposal;
import bisq.core.dao.state.model.governance.Proposal;
Expand Down Expand Up @@ -200,7 +201,10 @@ protected void activate() {
daoFacade.addBsqStateListener(this);
cyclesTableView.getSelectionModel().selectedItemProperty().addListener(selectedVoteResultListItemListener);

fillCycleList();
if (daoStateService.isParseBlockChainComplete()) {
fillCycleList();
}

exportButton.setOnAction(event -> {
JsonElement cyclesJsonArray = getVotingHistoryJson();
GUIUtil.exportJSON("voteResultsHistory.json", cyclesJsonArray, (Stage) root.getScene().getWindow());
Expand Down Expand Up @@ -234,6 +238,20 @@ protected void deactivate() {

@Override
public void onParseBlockCompleteAfterBatchProcessing(Block block) {
int chainHeight = daoStateService.getChainHeight();
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<Cycle> optionalCurrentCycle = cyclesAdded.stream()
.filter(cycle -> cycle.isInCycle(chainHeight))
.findAny();
optionalCurrentCycle.ifPresent(cyclesAdded::remove);
Optional<CycleListItem> optionalCurrentCycleListItem = cycleListItemList.stream()
.filter(cycleListItem -> cycleListItem.getResultsOfCycle().getCycle().isInCycle(chainHeight))
.findAny();
optionalCurrentCycleListItem.ifPresent(cycleListItemList::remove);
}

fillCycleList();
}

Expand Down Expand Up @@ -351,8 +369,10 @@ private void onSelectProposalResultListItem(ProposalListItem item) {
}
}

private void showProposalResultWindow(EvaluatedProposal evaluatedProposal, Ballot ballot,
boolean isVoteIncludedInResult, SortedList<VoteListItem> sortedVoteListItemList) {
private void showProposalResultWindow(EvaluatedProposal evaluatedProposal,
Ballot ballot,
boolean isVoteIncludedInResult,
SortedList<VoteListItem> sortedVoteListItemList) {
proposalResultsWindow.show(evaluatedProposal, ballot, isVoteIncludedInResult, sortedVoteListItemList);
}

Expand Down