Rename Proposal to Ballot and ProposalPayload to Proposal

This commit is contained in:
Manfred Karrer 2018-04-18 22:26:55 -05:00
parent 945663b33d
commit 27ac78f98b
No known key found for this signature in database
GPG key ID: 401250966A6B2C46
9 changed files with 119 additions and 115 deletions

View file

@ -28,13 +28,13 @@ import bisq.desktop.util.BsqFormatter;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.consensus.period.Phase;
import bisq.core.dao.consensus.period.UserThreadPeriodService;
import bisq.core.dao.consensus.state.events.payloads.Proposal;
import bisq.core.dao.consensus.vote.proposal.Ballot;
import bisq.core.dao.consensus.vote.proposal.MyProposalService;
import bisq.core.dao.consensus.vote.proposal.Proposal;
import bisq.core.dao.consensus.vote.proposal.ProposalListService;
import bisq.core.dao.consensus.state.events.payloads.ProposalPayload;
import bisq.core.dao.consensus.vote.proposal.ProposalService;
import bisq.core.dao.consensus.vote.proposal.param.ParamService;
import bisq.core.dao.consensus.vote.proposal.param.ChangeParamService;
import bisq.core.dao.presentation.period.PeriodServiceFacade;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
@ -74,7 +74,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
protected final MyProposalService myProposalService;
protected final StateServiceFacade stateService;
protected final ParamService paramService;
protected final ChangeParamService changeParamService;
protected final ProposalListService proposalListService;
protected final ProposalService proposalService;
protected final BsqWalletService bsqWalletService;
@ -90,9 +90,9 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
protected int gridRow = 0;
protected GridPane detailsGridPane, gridPane;
protected ProposalListItem selectedProposalListItem;
protected ListChangeListener<Proposal> proposalListChangeListener;
protected ListChangeListener<Ballot> proposalListChangeListener;
protected ChangeListener<Phase> phaseChangeListener;
protected final UserThreadPeriodService periodService;
protected final PeriodServiceFacade periodService;
protected Phase currentPhase;
protected Subscription phaseSubscription;
private ScrollPane proposalDisplayView;
@ -108,8 +108,8 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
ProposalService proposalService,
BsqWalletService bsqWalletService,
StateServiceFacade stateService,
ParamService paramService,
UserThreadPeriodService periodService,
ChangeParamService changeParamService,
PeriodServiceFacade periodService,
BsqFormatter bsqFormatter,
BSFormatter btcFormatter) {
this.myProposalService = myProposalService;
@ -117,7 +117,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
this.proposalService = proposalService;
this.bsqWalletService = bsqWalletService;
this.stateService = stateService;
this.paramService = paramService;
this.changeParamService = changeParamService;
this.periodService = periodService;
this.bsqFormatter = bsqFormatter;
this.btcFormatter = btcFormatter;
@ -211,14 +211,14 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
proposalDisplayView.setManaged(false);
}
protected void showProposalDisplay(Proposal proposal) {
protected void showProposalDisplay(Ballot ballot) {
proposalDisplayView.setVisible(true);
proposalDisplayView.setManaged(true);
proposalDisplay.createAllFields(Res.get("dao.proposal.selectedProposal"), 0, 0, proposal.getType(),
proposalDisplay.createAllFields(Res.get("dao.proposal.selectedProposal"), 0, 0, ballot.getType(),
false, false);
proposalDisplay.setEditable(false);
proposalDisplay.applyProposalPayload(proposal.getProposalPayload());
proposalDisplay.applyProposalPayload(ballot.getProposal());
}
@ -229,7 +229,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
protected void onSelectProposal(ProposalListItem item) {
selectedProposalListItem = item;
if (item != null)
showProposalDisplay(item.getProposal());
showProposalDisplay(item.getBallot());
else
hideProposalDisplay();
}
@ -248,7 +248,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
abstract protected void updateProposalList();
protected void doUpdateProposalList(List<Proposal> list) {
protected void doUpdateProposalList(List<Ballot> list) {
proposalListItems.forEach(ProposalListItem::cleanup);
proposalListItems.setAll(list.stream()
@ -295,14 +295,14 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
public void updateItem(final ProposalListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(bsqFormatter.formatDateTime(item.getProposal().getProposalPayload().getCreationDate()));
setText(bsqFormatter.formatDateTime(item.getBallot().getProposal().getCreationDate()));
else
setText("");
}
};
}
});
dateColumn.setComparator(Comparator.comparing(o3 -> o3.getProposal().getProposalPayload().getCreationDate()));
dateColumn.setComparator(Comparator.comparing(o3 -> o3.getBallot().getProposal().getCreationDate()));
dateColumn.setSortType(TableColumn.SortType.DESCENDING);
tableView.getColumns().add(dateColumn);
tableView.getSortOrder().add(dateColumn);
@ -320,14 +320,14 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
public void updateItem(final ProposalListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(item.getProposal().getProposalPayload().getName());
setText(item.getBallot().getProposal().getName());
else
setText("");
}
};
}
});
nameColumn.setComparator(Comparator.comparing(o2 -> o2.getProposal().getProposalPayload().getName()));
nameColumn.setComparator(Comparator.comparing(o2 -> o2.getBallot().getProposal().getName()));
tableView.getColumns().add(nameColumn);
TableColumn<ProposalListItem, ProposalListItem> titleColumn = new AutoTooltipTableColumn<>(Res.get("dao.proposal.title"));
@ -344,14 +344,14 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
public void updateItem(final ProposalListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null)
setText(item.getProposal().getProposalPayload().getTitle());
setText(item.getBallot().getProposal().getTitle());
else
setText("");
}
};
}
});
titleColumn.setComparator(Comparator.comparing(o2 -> o2.getProposal().getProposalPayload().getTitle()));
titleColumn.setComparator(Comparator.comparing(o2 -> o2.getBallot().getProposal().getTitle()));
tableView.getColumns().add(titleColumn);
TableColumn<ProposalListItem, ProposalListItem> uidColumn = new AutoTooltipTableColumn<>(Res.get("shared.id"));
@ -370,11 +370,11 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
public void updateItem(final ProposalListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
final Proposal proposal = item.getProposal();
final ProposalPayload proposalPayload = proposal.getProposalPayload();
field = new HyperlinkWithIcon(proposalPayload.getShortId());
final Ballot ballot = item.getBallot();
final Proposal proposal = ballot.getProposal();
field = new HyperlinkWithIcon(proposal.getShortId());
field.setOnAction(event -> {
new ProposalDetailsWindow(bsqFormatter, bsqWalletService, proposalPayload).show();
new ProposalDetailsWindow(bsqFormatter, bsqWalletService, proposal).show();
});
field.setTooltip(new Tooltip(Res.get("tooltip.openPopupForDetails")));
setGraphic(field);
@ -387,7 +387,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
};
}
});
uidColumn.setComparator(Comparator.comparing(o -> o.getProposal().getUid()));
uidColumn.setComparator(Comparator.comparing(o -> o.getBallot().getUid()));
tableView.getColumns().add(uidColumn);
}

View file

@ -22,7 +22,7 @@ import bisq.desktop.util.BsqFormatter;
import bisq.desktop.util.Layout;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.consensus.state.events.payloads.ProposalPayload;
import bisq.core.dao.consensus.state.events.payloads.Proposal;
import bisq.core.locale.Res;
import javafx.geometry.Insets;
@ -36,7 +36,7 @@ public class ProposalDetailsWindow extends Overlay<ProposalDetailsWindow> {
protected static final Logger log = LoggerFactory.getLogger(ProposalDetailsWindow.class);
private final BsqFormatter bsqFormatter;
private final BsqWalletService bsqWalletService;
private ProposalPayload proposalPayload;
private Proposal proposal;
private ProposalDisplay proposalDisplay;
@ -44,10 +44,10 @@ public class ProposalDetailsWindow extends Overlay<ProposalDetailsWindow> {
// Public API
///////////////////////////////////////////////////////////////////////////////////////////
public ProposalDetailsWindow(BsqFormatter bsqFormatter, BsqWalletService bsqWalletService, ProposalPayload proposalPayload) {
public ProposalDetailsWindow(BsqFormatter bsqFormatter, BsqWalletService bsqWalletService, Proposal proposal) {
this.bsqFormatter = bsqFormatter;
this.bsqWalletService = bsqWalletService;
this.proposalPayload = proposalPayload;
this.proposal = proposal;
type = Type.Confirmation;
width = 950;
@ -58,10 +58,10 @@ public class ProposalDetailsWindow extends Overlay<ProposalDetailsWindow> {
proposalDisplay = new ProposalDisplay(gridPane, bsqFormatter, bsqWalletService, null);
proposalDisplay.createAllFields(Res.get("dao.proposal.details"), 1, Layout.GROUP_DISTANCE,
proposalPayload.getType(), false, true);
proposal.getType(), false, true);
proposalDisplay.setEditable(false);
proposalDisplay.applyProposalPayload(proposalPayload);
proposalDisplay.applyProposalPayload(proposal);
closeButton = addButtonAfterGroup(gridPane, proposalDisplay.incrementAndGetGridRow(), Res.get("shared.close"));
closeButton.setOnAction(e -> doClose());

View file

@ -28,11 +28,11 @@ import bisq.desktop.util.validation.BsqAddressValidator;
import bisq.desktop.util.validation.BsqValidator;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.consensus.state.events.payloads.CompensationRequestProposal;
import bisq.core.dao.consensus.state.events.payloads.Proposal;
import bisq.core.dao.consensus.vote.proposal.ProposalConsensus;
import bisq.core.dao.consensus.state.events.payloads.ProposalPayload;
import bisq.core.dao.consensus.vote.proposal.ProposalType;
import bisq.core.dao.consensus.vote.proposal.compensation.CompensationRequestConsensus;
import bisq.core.dao.consensus.state.events.payloads.CompensationRequestPayload;
import bisq.core.locale.Res;
import bisq.core.provider.fee.FeeService;
@ -153,26 +153,26 @@ public class ProposalDisplay {
Res.get("dao.proposal.display.txId"), "").second;
}
public void applyProposalPayload(ProposalPayload proposalPayload) {
public void applyProposalPayload(Proposal proposal) {
if (uidTextField != null)
uidTextField.setText(proposalPayload.getUid());
nameTextField.setText(proposalPayload.getName());
titleTextField.setText(proposalPayload.getTitle());
descriptionTextArea.setText(proposalPayload.getDescription());
uidTextField.setText(proposal.getUid());
nameTextField.setText(proposal.getName());
titleTextField.setText(proposal.getTitle());
descriptionTextArea.setText(proposal.getDescription());
linkInputTextField.setVisible(false);
linkInputTextField.setManaged(false);
linkHyperlinkWithIcon.setVisible(true);
linkHyperlinkWithIcon.setManaged(true);
linkHyperlinkWithIcon.setText(proposalPayload.getLink());
linkHyperlinkWithIcon.setOnAction(e -> GUIUtil.openWebPage(proposalPayload.getLink()));
if (proposalPayload instanceof CompensationRequestPayload) {
CompensationRequestPayload compensationRequestPayload = (CompensationRequestPayload) proposalPayload;
Objects.requireNonNull(requestedBsqTextField).setText(bsqFormatter.formatCoinWithCode(compensationRequestPayload.getRequestedBsq()));
linkHyperlinkWithIcon.setText(proposal.getLink());
linkHyperlinkWithIcon.setOnAction(e -> GUIUtil.openWebPage(proposal.getLink()));
if (proposal instanceof CompensationRequestProposal) {
CompensationRequestProposal compensationRequestProposal = (CompensationRequestProposal) proposal;
Objects.requireNonNull(requestedBsqTextField).setText(bsqFormatter.formatCoinWithCode(compensationRequestProposal.getRequestedBsq()));
if (bsqAddressTextField != null)
bsqAddressTextField.setText(compensationRequestPayload.getBsqAddress());
bsqAddressTextField.setText(compensationRequestProposal.getBsqAddress());
}
if (txIdTextField != null)
txIdTextField.setup(proposalPayload.getTxId());
txIdTextField.setup(proposal.getTxId());
}
public void clearForm() {

View file

@ -24,14 +24,14 @@ import bisq.desktop.util.BsqFormatter;
import bisq.core.btc.listeners.TxConfidenceListener;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.consensus.period.Phase;
import bisq.core.dao.consensus.period.UserThreadPeriodService;
import bisq.core.dao.consensus.state.Block;
import bisq.core.dao.consensus.state.BlockListener;
import bisq.core.dao.consensus.state.blockchain.Tx;
import bisq.core.dao.consensus.vote.BooleanVote;
import bisq.core.dao.consensus.vote.Vote;
import bisq.core.dao.consensus.vote.proposal.Proposal;
import bisq.core.dao.consensus.vote.proposal.Ballot;
import bisq.core.dao.consensus.vote.proposal.ProposalService;
import bisq.core.dao.presentation.period.PeriodServiceFacade;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
@ -57,9 +57,9 @@ import lombok.extern.slf4j.Slf4j;
@EqualsAndHashCode
public class ProposalListItem implements BlockListener {
@Getter
private final Proposal proposal;
private final Ballot ballot;
private final ProposalService proposalService;
private final UserThreadPeriodService periodService;
private final PeriodServiceFacade periodService;
private final BsqWalletService bsqWalletService;
private final StateServiceFacade stateService;
private final BsqFormatter bsqFormatter;
@ -80,13 +80,13 @@ public class ProposalListItem implements BlockListener {
private Runnable onRemoveHandler;
private Node actionNode;
ProposalListItem(Proposal proposal,
ProposalListItem(Ballot ballot,
ProposalService proposalService,
UserThreadPeriodService periodService,
PeriodServiceFacade periodService,
BsqWalletService bsqWalletService,
StateServiceFacade stateService,
BsqFormatter bsqFormatter) {
this.proposal = proposal;
this.ballot = ballot;
this.proposalService = proposalService;
this.periodService = periodService;
this.bsqWalletService = bsqWalletService;
@ -112,7 +112,7 @@ public class ProposalListItem implements BlockListener {
stateService.addBlockListener(this);
phaseChangeListener = (observable, oldValue, newValue) -> {
applyState(newValue, proposal.getVote());
applyState(newValue, ballot.getVote());
};
voteResultChangeListener = (observable, oldValue, newValue) -> {
@ -120,20 +120,20 @@ public class ProposalListItem implements BlockListener {
};
periodService.phaseProperty().addListener(phaseChangeListener);
proposal.getVoteResultProperty().addListener(voteResultChangeListener);
ballot.getVoteResultProperty().addListener(voteResultChangeListener);
}
public void applyState(Phase newValue, Vote vote) {
actionButton.setText("");
actionButton.setVisible(false);
actionButton.setOnAction(null);
final boolean isTxInPastCycle = periodService.isTxInPastCycle(proposal.getTxId(),
final boolean isTxInPastCycle = periodService.isTxInPastCycle(ballot.getTxId(),
stateService.getChainHeight());
switch (newValue) {
case UNDEFINED:
break;
case PROPOSAL:
if (proposalService.isMine(proposal.getProposalPayload())) {
if (proposalService.isMine(ballot.getProposal())) {
actionButton.setVisible(!isTxInPastCycle);
actionButtonIconView.setVisible(actionButton.isVisible());
actionButton.setText(Res.get("shared.remove"));
@ -152,7 +152,7 @@ public class ProposalListItem implements BlockListener {
if (!isTxInPastCycle) {
actionNode = actionButtonIconView;
actionButton.setVisible(false);
if (proposal.getVote() != null) {
if (ballot.getVote() != null) {
actionButtonIconView.setVisible(true);
if (vote instanceof BooleanVote) {
if (((BooleanVote) vote).isAccepted()) {
@ -199,7 +199,7 @@ public class ProposalListItem implements BlockListener {
private void setupConfidence() {
final Tx tx = stateService.getTxMap().get(proposal.getProposalPayload().getTxId());
final Tx tx = stateService.getTxMap().get(ballot.getProposal().getTxId());
if (tx != null) {
final String txId = tx.getId();
@ -249,7 +249,7 @@ public class ProposalListItem implements BlockListener {
bsqWalletService.removeTxConfidenceListener(txConfidenceListener);
periodService.phaseProperty().removeListener(phaseChangeListener);
proposal.getVoteResultProperty().removeListener(voteResultChangeListener);
ballot.getVoteResultProperty().removeListener(voteResultChangeListener);
}
private void updateConfidence(TransactionConfidence.ConfidenceType confidenceType, int depthInBlocks, int numBroadcastPeers) {

View file

@ -34,15 +34,15 @@ import bisq.core.btc.exceptions.WalletException;
import bisq.core.btc.wallet.BsqBalanceListener;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.consensus.period.Phase;
import bisq.core.dao.consensus.period.UserThreadPeriodService;
import bisq.core.dao.consensus.vote.BooleanVote;
import bisq.core.dao.consensus.vote.blindvote.BlindVoteConsensus;
import bisq.core.dao.consensus.vote.myvote.MyVoteService;
import bisq.core.dao.consensus.vote.proposal.Ballot;
import bisq.core.dao.consensus.vote.proposal.MyProposalService;
import bisq.core.dao.consensus.vote.proposal.Proposal;
import bisq.core.dao.consensus.vote.proposal.ProposalListService;
import bisq.core.dao.consensus.vote.proposal.ProposalService;
import bisq.core.dao.consensus.vote.proposal.param.ParamService;
import bisq.core.dao.consensus.vote.proposal.param.ChangeParamService;
import bisq.core.dao.presentation.period.PeriodServiceFacade;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
@ -92,16 +92,16 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
private ActiveProposalsView(MyProposalService myProposalService,
ProposalListService proposalListService,
ProposalService proposalService,
UserThreadPeriodService periodService,
PeriodServiceFacade periodService,
MyVoteService myVoteService,
BsqWalletService bsqWalletService,
StateServiceFacade stateService,
ParamService paramService,
ChangeParamService changeParamService,
BsqFormatter bsqFormatter,
BSFormatter btcFormatter) {
super(myProposalService, proposalListService, proposalService, bsqWalletService, stateService,
paramService, periodService, bsqFormatter, btcFormatter);
changeParamService, periodService, bsqFormatter, btcFormatter);
this.myVoteService = myVoteService;
}
@ -119,7 +119,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
protected void activate() {
super.activate();
proposalListService.getActiveOrMyUnconfirmedProposals().addListener(proposalListChangeListener);
proposalListService.getActiveOrMyUnconfirmedBallots().addListener(proposalListChangeListener);
bsqWalletService.addBsqBalanceListener(this);
onUpdateBalances(bsqWalletService.getAvailableBalance(),
@ -131,7 +131,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
voteButton.setOnAction(e -> {
// TODO verify stake
Coin stake = bsqFormatter.parseToCoin(stakeInputTextField.getText());
final Coin fee = BlindVoteConsensus.getFee(paramService, stateService.getChainHeight());
final Coin fee = BlindVoteConsensus.getFee(changeParamService, stateService.getChainHeight());
Transaction dummyTx = null;
try {
// We create a tx with dummy opreturn data to get the mining fee for confirmation popup
@ -170,7 +170,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
protected void deactivate() {
super.deactivate();
proposalListService.getActiveOrMyUnconfirmedProposals().removeListener(proposalListChangeListener);
proposalListService.getActiveOrMyUnconfirmedBallots().removeListener(proposalListChangeListener);
bsqWalletService.removeBsqBalanceListener(this);
}
@ -243,17 +243,17 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
}
private void onAccept() {
selectedProposalListItem.getProposal().setVote(new BooleanVote(true));
selectedProposalListItem.getBallot().setVote(new BooleanVote(true));
updateStateAfterVote();
}
private void onReject() {
selectedProposalListItem.getProposal().setVote(new BooleanVote(false));
selectedProposalListItem.getBallot().setVote(new BooleanVote(false));
updateStateAfterVote();
}
private void onCancelVote() {
selectedProposalListItem.getProposal().setVote(null);
selectedProposalListItem.getBallot().setVote(null);
updateStateAfterVote();
}
@ -270,12 +270,12 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
}
if (selectedProposalListItem != null &&
proposalDisplay != null &&
!periodService.isTxInPastCycle(selectedProposalListItem.getProposal().getTxId(),
!periodService.isTxInPastCycle(selectedProposalListItem.getBallot().getTxId(),
stateService.getChainHeight())) {
final Proposal proposal = selectedProposalListItem.getProposal();
final Ballot ballot = selectedProposalListItem.getBallot();
switch (phase) {
case PROPOSAL:
if (proposalService.isMine(proposal.getProposalPayload())) {
if (proposalService.isMine(ballot.getProposal())) {
if (removeButton == null) {
removeButton = addButtonAfterGroup(detailsGridPane, proposalDisplay.incrementAndGetGridRow(), Res.get("dao.proposal.active.remove"));
removeButton.setOnAction(event -> onRemove());
@ -334,7 +334,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
@Override
protected void updateProposalList() {
doUpdateProposalList(proposalListService.getActiveOrMyUnconfirmedProposals());
doUpdateProposalList(proposalListService.getActiveOrMyUnconfirmedBallots());
}
private void updateStateAfterVote() {
@ -351,7 +351,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
}
private void onRemove() {
if (myProposalService.removeProposal(selectedProposalListItem.getProposal()))
if (myProposalService.removeProposal(selectedProposalListItem.getBallot()))
hideProposalDisplay();
else
new Popup<>().warning(Res.get("dao.proposal.active.remove.failed")).show();
@ -396,7 +396,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
ActiveProposalsView.this.selectedProposalListItem = item;
ActiveProposalsView.this.onRemove();
});
item.applyState(currentPhase, item.getProposal().getVoteResultProperty().get());
item.applyState(currentPhase, item.getBallot().getVoteResultProperty().get());
}
} else {
setGraphic(null);

View file

@ -23,11 +23,11 @@ import bisq.desktop.util.BSFormatter;
import bisq.desktop.util.BsqFormatter;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.consensus.period.UserThreadPeriodService;
import bisq.core.dao.consensus.vote.proposal.MyProposalService;
import bisq.core.dao.consensus.vote.proposal.ProposalListService;
import bisq.core.dao.consensus.vote.proposal.ProposalService;
import bisq.core.dao.consensus.vote.proposal.param.ParamService;
import bisq.core.dao.consensus.vote.proposal.param.ChangeParamService;
import bisq.core.dao.presentation.period.PeriodServiceFacade;
import bisq.core.dao.presentation.state.StateServiceFacade;
import javax.inject.Inject;
@ -43,15 +43,15 @@ public class ClosedProposalsView extends BaseProposalView {
private ClosedProposalsView(MyProposalService myProposalService,
ProposalListService proposalListService,
ProposalService proposalService,
UserThreadPeriodService periodService,
PeriodServiceFacade periodService,
BsqWalletService bsqWalletService,
StateServiceFacade stateService,
ParamService paramService,
ChangeParamService changeParamService,
BsqFormatter bsqFormatter,
BSFormatter btcFormatter) {
super(myProposalService, proposalListService, proposalService, bsqWalletService, stateService,
paramService, periodService, bsqFormatter, btcFormatter);
changeParamService, periodService, bsqFormatter, btcFormatter);
}
@Override
@ -65,18 +65,18 @@ public class ClosedProposalsView extends BaseProposalView {
@Override
protected void activate() {
super.activate();
proposalListService.getClosedProposals().addListener(proposalListChangeListener);
proposalListService.getClosedBallots().addListener(proposalListChangeListener);
}
@Override
protected void deactivate() {
super.deactivate();
proposalListService.getClosedProposals().removeListener(proposalListChangeListener);
proposalListService.getClosedBallots().removeListener(proposalListChangeListener);
}
@Override
protected void updateProposalList() {
doUpdateProposalList(proposalListService.getClosedProposals());
doUpdateProposalList(proposalListService.getClosedBallots());
}
}

View file

@ -23,12 +23,14 @@ import bisq.desktop.components.SeparatedPhaseBars;
import bisq.desktop.util.Layout;
import bisq.core.dao.consensus.period.Phase;
import bisq.core.dao.consensus.period.UserThreadPeriodService;
import bisq.core.dao.consensus.state.Block;
import bisq.core.dao.consensus.state.BlockListener;
import bisq.core.dao.presentation.period.PeriodServiceFacade;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
import bisq.common.UserThread;
import javax.inject.Inject;
import javafx.scene.layout.AnchorPane;
@ -48,7 +50,7 @@ import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
public class ProposalDashboardView extends ActivatableView<GridPane, Void> implements BlockListener {
private List<SeparatedPhaseBars.SeparatedPhaseBarsItem> phaseBarsItems;
private final UserThreadPeriodService periodService;
private final PeriodServiceFacade periodService;
private final StateServiceFacade stateService;
private Phase currentPhase;
private Subscription phaseSubscription;
@ -62,7 +64,7 @@ public class ProposalDashboardView extends ActivatableView<GridPane, Void> imple
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private ProposalDashboardView(UserThreadPeriodService periodService, StateServiceFacade stateService) {
private ProposalDashboardView(PeriodServiceFacade periodService, StateServiceFacade stateService) {
this.periodService = periodService;
this.stateService = stateService;
}
@ -123,14 +125,16 @@ public class ProposalDashboardView extends ActivatableView<GridPane, Void> imple
});
});
stateService.addBlockListener(this);
onChainHeightChanged(periodService.getChainHeight());
periodService.addBlockListener(this);
// We need to delay as otherwise the periodService has not been updated yet.
UserThread.execute(() -> onChainHeightChanged(periodService.getChainHeight()));
}
@Override
protected void deactivate() {
super.deactivate();
stateService.removeBlockListener(this);
periodService.removeBlockListener(this);
phaseSubscription.unsubscribe();
}

View file

@ -31,14 +31,14 @@ import bisq.core.btc.exceptions.WalletException;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.InsufficientBsqException;
import bisq.core.btc.wallet.WalletsSetup;
import bisq.core.dao.consensus.vote.proposal.Ballot;
import bisq.core.dao.consensus.vote.proposal.MyProposalService;
import bisq.core.dao.consensus.vote.proposal.Proposal;
import bisq.core.dao.consensus.vote.proposal.ProposalConsensus;
import bisq.core.dao.consensus.vote.proposal.ProposalType;
import bisq.core.dao.consensus.vote.proposal.ValidationException;
import bisq.core.dao.consensus.vote.proposal.compensation.CompensationRequestService;
import bisq.core.dao.consensus.vote.proposal.generic.GenericProposalService;
import bisq.core.dao.consensus.vote.proposal.param.ParamService;
import bisq.core.dao.consensus.vote.proposal.param.ChangeParamService;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
import bisq.core.provider.fee.FeeService;
@ -87,7 +87,7 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> {
private final CompensationRequestService compensationRequestService;
private final GenericProposalService genericProposalService;
private final StateServiceFacade stateService;
private final ParamService paramService;
private final ChangeParamService changeParamService;
private final BSFormatter btcFormatter;
private final BsqFormatter bsqFormatter;
private ComboBox<ProposalType> proposalTypeComboBox;
@ -108,7 +108,7 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> {
CompensationRequestService compensationRequestService,
GenericProposalService genericProposalService,
StateServiceFacade stateService,
ParamService paramService,
ChangeParamService changeParamService,
BSFormatter btcFormatter,
BsqFormatter bsqFormatter) {
this.bsqWalletService = bsqWalletService;
@ -119,7 +119,7 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> {
this.compensationRequestService = compensationRequestService;
this.genericProposalService = genericProposalService;
this.stateService = stateService;
this.paramService = paramService;
this.changeParamService = changeParamService;
this.btcFormatter = btcFormatter;
this.bsqFormatter = bsqFormatter;
}
@ -167,15 +167,15 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> {
private void publishProposal(ProposalType type) {
try {
final Tuple2<Proposal, Transaction> tuple2 = createProposal(type);
Proposal proposal = tuple2.first;
final Tuple2<Ballot, Transaction> tuple2 = createProposal(type);
Ballot ballot = tuple2.first;
Transaction transaction = tuple2.second;
Coin miningFee = transaction.getFee();
int txSize = transaction.bitcoinSerialize().length;
final Coin fee = ProposalConsensus.getFee(paramService, stateService.getChainHeight());
final Coin fee = ProposalConsensus.getFee(changeParamService, stateService.getChainHeight());
GUIUtil.showBsqFeeInfoPopup(fee, miningFee, txSize, bsqFormatter, btcFormatter,
Res.get("dao.proposal"), () -> publishProposal(proposal, transaction));
Res.get("dao.proposal"), () -> publishProposal(ballot, transaction));
} catch (InsufficientMoneyException e) {
BSFormatter formatter = e instanceof InsufficientBsqException ? bsqFormatter : btcFormatter;
@ -197,8 +197,8 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> {
}
}
private void publishProposal(Proposal proposal, Transaction transaction) {
myProposalService.publishProposal(proposal,
private void publishProposal(Ballot ballot, Transaction transaction) {
myProposalService.publishProposal(ballot,
transaction,
() -> {
proposalDisplay.clearForm();
@ -208,7 +208,7 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> {
errorMessage -> new Popup<>().warning(errorMessage).show());
}
private Tuple2<Proposal, Transaction> createProposal(ProposalType type)
private Tuple2<Ballot, Transaction> createProposal(ProposalType type)
throws InsufficientMoneyException, TransactionVerificationException, ValidationException,
WalletException, IOException {

View file

@ -30,15 +30,15 @@ import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.Layout;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.consensus.period.UserThreadPeriodService;
import bisq.core.dao.consensus.vote.BooleanVote;
import bisq.core.dao.consensus.vote.Vote;
import bisq.core.dao.consensus.vote.myvote.MyVoteService;
import bisq.core.dao.consensus.vote.proposal.BallotList;
import bisq.core.dao.consensus.vote.proposal.MyProposalService;
import bisq.core.dao.consensus.vote.proposal.ProposalList;
import bisq.core.dao.consensus.vote.proposal.ProposalListService;
import bisq.core.dao.consensus.vote.proposal.ProposalService;
import bisq.core.dao.consensus.vote.proposal.param.ParamService;
import bisq.core.dao.consensus.vote.proposal.param.ChangeParamService;
import bisq.core.dao.presentation.period.PeriodServiceFacade;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
import bisq.core.user.Preferences;
@ -93,17 +93,17 @@ public class MyVotesView extends BaseProposalView {
private MyVotesView(MyProposalService myProposalService,
ProposalListService proposalListService,
ProposalService proposalService,
UserThreadPeriodService periodService,
PeriodServiceFacade periodService,
BsqWalletService bsqWalletService,
StateServiceFacade stateService,
ParamService paramService,
ChangeParamService changeParamService,
BsqFormatter bsqFormatter,
BSFormatter btcFormatter,
MyVoteService myVoteService,
Preferences preferences) {
super(myProposalService, proposalListService, proposalService, bsqWalletService, stateService,
paramService, periodService, bsqFormatter, btcFormatter);
changeParamService, periodService, bsqFormatter, btcFormatter);
this.myVoteService = myVoteService;
this.preferences = preferences;
}
@ -182,7 +182,7 @@ public class MyVotesView extends BaseProposalView {
// Handler
///////////////////////////////////////////////////////////////////////////////////////////
private void onShowProposalList(ProposalList proposalList) {
private void onShowProposalList(BallotList ballotList) {
}
@ -194,7 +194,7 @@ public class MyVotesView extends BaseProposalView {
@Override
protected void updateProposalList() {
if (selectedVoteListItem != null)
doUpdateProposalList(selectedVoteListItem.getMyVote().getProposalList().getList());
doUpdateProposalList(selectedVoteListItem.getMyVote().getBallotList().getList());
}
@ -249,9 +249,9 @@ public class MyVotesView extends BaseProposalView {
super.updateItem(item, empty);
if (item != null && !empty) {
ProposalList proposalList = item.getMyVote().getProposalList();
BallotList ballotList = item.getMyVote().getBallotList();
HyperlinkWithIcon field = new HyperlinkWithIcon(Res.get("dao.proposal.myVotes.showProposalList"), AwesomeIcon.INFO_SIGN);
field.setOnAction(event -> onShowProposalList(proposalList));
field.setOnAction(event -> onShowProposalList(ballotList));
field.setTooltip(new Tooltip(Res.get("dao.proposal.myVotes.tooltip.showProposalList")));
setGraphic(field);
} else {
@ -378,7 +378,7 @@ public class MyVotesView extends BaseProposalView {
if (item != null && !empty) {
actionButtonIconView = new ImageView();
Vote vote = item.getProposal().getVote();
Vote vote = item.getBallot().getVote();
if (vote instanceof BooleanVote) {
if (((BooleanVote) vote).isAccepted()) {
actionButtonIconView.setId("accepted");