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 UI treats rejected proposals as accepted #2528

Merged
Merged
Show file tree
Hide file tree
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 @@ -33,6 +33,7 @@
import bisq.core.dao.state.model.blockchain.Block;
import bisq.core.dao.state.model.blockchain.Tx;
import bisq.core.dao.state.model.blockchain.TxType;
import bisq.core.dao.state.model.governance.EvaluatedProposal;
import bisq.core.dao.state.model.governance.RemoveAssetProposal;
import bisq.core.locale.CurrencyUtil;
import bisq.core.trade.statistics.TradeStatistics2;
Expand Down Expand Up @@ -286,7 +287,7 @@ public void onParseBlockCompleteAfterBatchProcessing(Block block) {
///////////////////////////////////////////////////////////////////////////////////////////

public boolean wasAssetRemovedByVoting(String tickerSymbol) {
boolean isRemoved = getRemoveAssetProposalStream()
boolean isRemoved = getAcceptedRemoveAssetProposalStream()
.anyMatch(proposal -> proposal.getTickerSymbol().equals(tickerSymbol));
if (isRemoved)
log.info("Asset '{}' was removed", CurrencyUtil.getNameAndCode(tickerSymbol));
Expand All @@ -306,9 +307,10 @@ private Optional<StatefulAsset> findAsset(String tickerSymbol) {
// Private
///////////////////////////////////////////////////////////////////////////////////////////

private Stream<RemoveAssetProposal> getRemoveAssetProposalStream() {
private Stream<RemoveAssetProposal> getAcceptedRemoveAssetProposalStream() {
return daoStateService.getEvaluatedProposalList().stream()
.filter(evaluatedProposal -> evaluatedProposal.getProposal() instanceof RemoveAssetProposal)
.filter(EvaluatedProposal::isAccepted)
.map(e -> ((RemoveAssetProposal) e.getProposal()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import bisq.core.dao.governance.bond.BondRepository;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.blockchain.TxOutput;
import bisq.core.dao.state.model.governance.EvaluatedProposal;
import bisq.core.dao.state.model.governance.Proposal;
import bisq.core.dao.state.model.governance.Role;
import bisq.core.dao.state.model.governance.RoleProposal;
Expand Down Expand Up @@ -62,7 +63,7 @@ public boolean isMyRole(Role role) {
Set<String> myWalletTransactionIds = bsqWalletService.getWalletTransactions().stream()
.map(Transaction::getHashAsString)
.collect(Collectors.toSet());
return getBondedRoleProposalStream()
return getAcceptedBondedRoleProposalStream()
.filter(roleProposal -> roleProposal.getRole().equals(role))
.map(Proposal::getTxId)
.anyMatch(myWalletTransactionIds::contains);
Expand Down Expand Up @@ -109,4 +110,11 @@ private Stream<RoleProposal> getBondedRoleProposalStream() {
.filter(evaluatedProposal -> evaluatedProposal.getProposal() instanceof RoleProposal)
.map(e -> ((RoleProposal) e.getProposal()));
}

private Stream<RoleProposal> getAcceptedBondedRoleProposalStream() {
return daoStateService.getEvaluatedProposalList().stream()
.filter(evaluatedProposal -> evaluatedProposal.getProposal() instanceof RoleProposal)
.filter(EvaluatedProposal::isAccepted)
.map(e -> ((RoleProposal) e.getProposal()));
}
}