mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 02:12:00 +01:00
Fix wrong values for vote and issuance
This commit is contained in:
parent
e1f23be46e
commit
5e07a94a3c
@ -19,24 +19,31 @@ package bisq.desktop.main.dao.results;
|
||||
|
||||
import bisq.desktop.main.dao.results.model.ResultsOfCycle;
|
||||
|
||||
import bisq.core.dao.state.BsqStateService;
|
||||
import bisq.core.dao.voting.proposal.compensation.CompensationProposal;
|
||||
import bisq.core.dao.voting.voteresult.EvaluatedProposal;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class ResultsListItem {
|
||||
private final BsqStateService bsqStateService;
|
||||
private final BsqFormatter bsqFormatter;
|
||||
@Getter
|
||||
private ResultsOfCycle resultsOfCycle;
|
||||
|
||||
public ResultsListItem(ResultsOfCycle resultsOfCycle,
|
||||
BsqStateService bsqStateService,
|
||||
BsqFormatter bsqFormatter) {
|
||||
this.resultsOfCycle = resultsOfCycle;
|
||||
this.bsqStateService = bsqStateService;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
}
|
||||
|
||||
@ -55,11 +62,20 @@ public class ResultsListItem {
|
||||
}
|
||||
|
||||
public String getStake() {
|
||||
return bsqFormatter.formatCoinWithCode(Coin.valueOf(resultsOfCycle.getTotalStake()));
|
||||
//TODO move to domain
|
||||
Map<String, Long> map = new HashMap<>();
|
||||
resultsOfCycle.getDecryptedVotesForCycle()
|
||||
.forEach(decryptedVote -> {
|
||||
decryptedVote.getBallotList().stream().forEach(ballot -> {
|
||||
map.putIfAbsent(decryptedVote.getBlindVoteTxId(), decryptedVote.getStake() + decryptedVote.getMerit(bsqStateService));
|
||||
});
|
||||
});
|
||||
return bsqFormatter.formatCoinWithCode(Coin.valueOf(map.values().stream().mapToLong(e -> e).sum()));
|
||||
}
|
||||
|
||||
public String getIssuance() {
|
||||
long totalIssuance = resultsOfCycle.getEvaluatedProposals().stream()
|
||||
.filter(EvaluatedProposal::isAccepted)
|
||||
.filter(e -> e.getProposal() instanceof CompensationProposal)
|
||||
.map(e -> (CompensationProposal) e.getProposal())
|
||||
.mapToLong(e -> e.getRequestedBsq().value)
|
||||
|
@ -299,7 +299,7 @@ public class ResultsView extends ActivatableViewAndModel<AnchorPane, Activatable
|
||||
proposalsForCycle,
|
||||
evaluatedProposalsForCycle,
|
||||
decryptedVotesForCycle);
|
||||
ResultsListItem resultsListItem = new ResultsListItem(resultsOfCycle, bsqFormatter);
|
||||
ResultsListItem resultsListItem = new ResultsListItem(resultsOfCycle, bsqStateService, bsqFormatter);
|
||||
itemList.add(resultsListItem);
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,7 @@ public class VotesPerProposalTableView extends BaseResultsTableView<VotesPerProp
|
||||
|
||||
@Override
|
||||
protected void fillList() {
|
||||
//TODO move to domain
|
||||
Map<String, EvaluatedProposalWithDecryptedVote> map = resultsOfCycle.getEvaluatedProposals().stream()
|
||||
.collect(Collectors.toMap(EvaluatedProposal::getProposalTxId,
|
||||
EvaluatedProposalWithDecryptedVote::new));
|
||||
|
@ -26,14 +26,14 @@ import bisq.core.util.BsqFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ResultsOfCycle {
|
||||
private final Cycle cycle;
|
||||
private final int cycleIndex;
|
||||
private final int numVotes, numAcceptedVotes, numRejectedVotes;
|
||||
private final long stakeOfAcceptedVotes;
|
||||
private final long stakeOfRejectedVotes;
|
||||
private BsqFormatter bsqFormatter;
|
||||
private long cycleStartTime;
|
||||
|
||||
@ -67,15 +67,5 @@ public class ResultsOfCycle {
|
||||
numRejectedVotes = evaluatedProposals.stream()
|
||||
.mapToInt(e -> e.getProposalVoteResult().getNumRejectedVotes())
|
||||
.sum();
|
||||
stakeOfAcceptedVotes = evaluatedProposals.stream()
|
||||
.mapToLong(e -> e.getProposalVoteResult().getStakeOfAcceptedVotes())
|
||||
.sum();
|
||||
stakeOfRejectedVotes = evaluatedProposals.stream()
|
||||
.mapToLong(e -> e.getProposalVoteResult().getStakeOfRejectedVotes())
|
||||
.sum();
|
||||
}
|
||||
|
||||
public long getTotalStake() {
|
||||
return stakeOfAcceptedVotes + stakeOfRejectedVotes;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user