use of bisq.core.dao.governance.proposal.param.ChangeParamProposal in project bisq-core by bisq-network.
the class VoteResultService method applyParamChange.
private void applyParamChange(Set<EvaluatedProposal> acceptedEvaluatedProposals, int chainHeight) {
Map<String, List<EvaluatedProposal>> evaluatedProposalsByParam = new HashMap<>();
acceptedEvaluatedProposals.forEach(evaluatedProposal -> {
if (evaluatedProposal.getProposal() instanceof ChangeParamProposal) {
ChangeParamProposal changeParamProposal = (ChangeParamProposal) evaluatedProposal.getProposal();
ParamChange paramChange = getParamChange(changeParamProposal, chainHeight);
if (paramChange != null) {
String paramName = paramChange.getParamName();
evaluatedProposalsByParam.putIfAbsent(paramName, new ArrayList<>());
evaluatedProposalsByParam.get(paramName).add(evaluatedProposal);
}
}
});
evaluatedProposalsByParam.forEach((key, list) -> {
if (list.size() == 1) {
applyAcceptedChangeParamProposal((ChangeParamProposal) list.get(0).getProposal(), chainHeight);
} else if (list.size() > 1) {
log.warn("There have been multiple winning param change proposals with the same item. " + "This is a sign of a social consensus failure. " + "We treat all requests as failed in such a case.");
// TODO remove code once we are 100% sure we stick with the above solution.
// We got multiple proposals for the same parameter. We check which one got the higher stake and that
// one will be the winner. If both have same stake none will be the winner.
/*list.sort(Comparator.comparing(ev -> ev.getProposalVoteResult().getStakeOfAcceptedVotes()));
Collections.reverse(list);
EvaluatedProposal first = list.get(0);
EvaluatedProposal second = list.get(1);
if (first.getProposalVoteResult().getStakeOfAcceptedVotes() >
second.getProposalVoteResult().getStakeOfAcceptedVotes()) {
applyAcceptedChangeParamProposal((ChangeParamProposal) first.getProposal(), chainHeight);
} else {
// Rare case that both have the same stake. We don't need to check for a third entry as if 2 have
// the same we are already in the abort case to reject all proposals with that param
log.warn("We got the rare case that multiple changeParamProposals have received the same stake. " +
"None will be accepted in such a case.\n" +
"EvaluatedProposal={}", list);
}*/
}
});
}
Aggregations