Apply separation of thread access to myVote domain

This commit is contained in:
Manfred Karrer 2018-04-20 22:04:23 -05:00
parent 46a440d84b
commit 4fd29557f5
No known key found for this signature in database
GPG key ID: 401250966A6B2C46
4 changed files with 24 additions and 25 deletions

View file

@ -32,8 +32,8 @@ import bisq.core.dao.consensus.period.Phase;
import bisq.core.dao.consensus.proposal.Proposal; import bisq.core.dao.consensus.proposal.Proposal;
import bisq.core.dao.consensus.proposal.param.ChangeParamService; import bisq.core.dao.consensus.proposal.param.ChangeParamService;
import bisq.core.dao.presentation.period.PeriodServiceFacade; import bisq.core.dao.presentation.period.PeriodServiceFacade;
import bisq.core.dao.presentation.proposal.MyBallotListService;
import bisq.core.dao.presentation.proposal.FilteredBallotListService; import bisq.core.dao.presentation.proposal.FilteredBallotListService;
import bisq.core.dao.presentation.proposal.MyBallotListService;
import bisq.core.dao.presentation.state.StateServiceFacade; import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res; import bisq.core.locale.Res;
@ -72,7 +72,7 @@ import java.util.stream.Collectors;
public abstract class BaseProposalView extends ActivatableView<GridPane, Void> { public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
protected final MyBallotListService myBallotListService; protected final MyBallotListService myBallotListService;
protected final StateServiceFacade stateService; protected final StateServiceFacade stateServiceFacade;
protected final PeriodServiceFacade periodServiceFacade; protected final PeriodServiceFacade periodServiceFacade;
protected final ChangeParamService changeParamService; protected final ChangeParamService changeParamService;
protected final FilteredBallotListService filteredBallotListService; protected final FilteredBallotListService filteredBallotListService;
@ -104,7 +104,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
protected BaseProposalView(MyBallotListService myBallotListService, protected BaseProposalView(MyBallotListService myBallotListService,
FilteredBallotListService filteredBallotListService, FilteredBallotListService filteredBallotListService,
BsqWalletService bsqWalletService, BsqWalletService bsqWalletService,
StateServiceFacade stateService, StateServiceFacade stateServiceFacade,
PeriodServiceFacade periodServiceFacade, PeriodServiceFacade periodServiceFacade,
ChangeParamService changeParamService, ChangeParamService changeParamService,
BsqFormatter bsqFormatter, BsqFormatter bsqFormatter,
@ -112,7 +112,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
this.myBallotListService = myBallotListService; this.myBallotListService = myBallotListService;
this.filteredBallotListService = filteredBallotListService; this.filteredBallotListService = filteredBallotListService;
this.bsqWalletService = bsqWalletService; this.bsqWalletService = bsqWalletService;
this.stateService = stateService; this.stateServiceFacade = stateServiceFacade;
this.periodServiceFacade = periodServiceFacade; this.periodServiceFacade = periodServiceFacade;
this.changeParamService = changeParamService; this.changeParamService = changeParamService;
this.bsqFormatter = bsqFormatter; this.bsqFormatter = bsqFormatter;
@ -252,7 +252,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
myBallotListService, myBallotListService,
periodServiceFacade, periodServiceFacade,
bsqWalletService, bsqWalletService,
stateService, stateServiceFacade,
bsqFormatter)) bsqFormatter))
.collect(Collectors.toSet())); .collect(Collectors.toSet()));

View file

@ -34,14 +34,13 @@ import bisq.core.btc.exceptions.WalletException;
import bisq.core.btc.wallet.BsqBalanceListener; import bisq.core.btc.wallet.BsqBalanceListener;
import bisq.core.btc.wallet.BsqWalletService; import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.consensus.ballot.Ballot; import bisq.core.dao.consensus.ballot.Ballot;
import bisq.core.dao.consensus.blindvote.BlindVoteConsensus;
import bisq.core.dao.consensus.period.Phase; import bisq.core.dao.consensus.period.Phase;
import bisq.core.dao.consensus.proposal.param.ChangeParamService; import bisq.core.dao.consensus.proposal.param.ChangeParamService;
import bisq.core.dao.consensus.vote.BooleanVote; import bisq.core.dao.consensus.vote.BooleanVote;
import bisq.core.dao.presentation.myvote.MyVoteService; import bisq.core.dao.presentation.myvote.MyVoteServiceFacade;
import bisq.core.dao.presentation.period.PeriodServiceFacade; import bisq.core.dao.presentation.period.PeriodServiceFacade;
import bisq.core.dao.presentation.proposal.MyBallotListService;
import bisq.core.dao.presentation.proposal.FilteredBallotListService; import bisq.core.dao.presentation.proposal.FilteredBallotListService;
import bisq.core.dao.presentation.proposal.MyBallotListService;
import bisq.core.dao.presentation.state.StateServiceFacade; import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res; import bisq.core.locale.Res;
@ -74,7 +73,7 @@ import static bisq.desktop.util.FormBuilder.*;
@FxmlView @FxmlView
public class ActiveProposalsView extends BaseProposalView implements BsqBalanceListener { public class ActiveProposalsView extends BaseProposalView implements BsqBalanceListener {
private final MyVoteService myVoteService; private final MyVoteServiceFacade myVoteServiceFacade;
private Button removeButton, acceptButton, rejectButton, cancelVoteButton, voteButton; private Button removeButton, acceptButton, rejectButton, cancelVoteButton, voteButton;
private InputTextField stakeInputTextField; private InputTextField stakeInputTextField;
@ -91,7 +90,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
private ActiveProposalsView(MyBallotListService myBallotListService, private ActiveProposalsView(MyBallotListService myBallotListService,
FilteredBallotListService filteredBallotListService, FilteredBallotListService filteredBallotListService,
PeriodServiceFacade periodServiceFacade, PeriodServiceFacade periodServiceFacade,
MyVoteService myVoteService, MyVoteServiceFacade myVoteServiceFacade,
BsqWalletService bsqWalletService, BsqWalletService bsqWalletService,
StateServiceFacade stateService, StateServiceFacade stateService,
ChangeParamService changeParamService, ChangeParamService changeParamService,
@ -100,7 +99,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
super(myBallotListService, filteredBallotListService, bsqWalletService, stateService, super(myBallotListService, filteredBallotListService, bsqWalletService, stateService,
periodServiceFacade, changeParamService, bsqFormatter, btcFormatter); periodServiceFacade, changeParamService, bsqFormatter, btcFormatter);
this.myVoteService = myVoteService; this.myVoteServiceFacade = myVoteServiceFacade;
} }
@Override @Override
@ -129,11 +128,11 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
voteButton.setOnAction(e -> { voteButton.setOnAction(e -> {
// TODO verify stake // TODO verify stake
Coin stake = bsqFormatter.parseToCoin(stakeInputTextField.getText()); Coin stake = bsqFormatter.parseToCoin(stakeInputTextField.getText());
final Coin fee = BlindVoteConsensus.getFee(changeParamService, stateService.getChainHeight()); final Coin blindVoteFee = myVoteServiceFacade.getBlindVoteFee();
Transaction dummyTx = null; Transaction dummyTx = null;
try { try {
// We create a tx with dummy opreturn data to get the mining fee for confirmation popup // We create a dummy tx to get the mining blindVoteFee for confirmation popup
dummyTx = myVoteService.getBlindVoteTx(stake, fee, new byte[22]); dummyTx = myVoteServiceFacade.getDummyBlindVoteTx(stake, blindVoteFee);
} catch (InsufficientMoneyException | WalletException | TransactionVerificationException exception) { } catch (InsufficientMoneyException | WalletException | TransactionVerificationException exception) {
new Popup<>().warning(exception.toString()).show(); new Popup<>().warning(exception.toString()).show();
} }
@ -141,7 +140,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
if (dummyTx != null) { if (dummyTx != null) {
Coin miningFee = dummyTx.getFee(); Coin miningFee = dummyTx.getFee();
int txSize = dummyTx.bitcoinSerialize().length; int txSize = dummyTx.bitcoinSerialize().length;
GUIUtil.showBsqFeeInfoPopup(fee, miningFee, txSize, bsqFormatter, btcFormatter, GUIUtil.showBsqFeeInfoPopup(blindVoteFee, miningFee, txSize, bsqFormatter, btcFormatter,
Res.get("dao.blindVote"), () -> publishBlindVote(stake)); Res.get("dao.blindVote"), () -> publishBlindVote(stake));
} }
}); });
@ -151,7 +150,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
private void publishBlindVote(Coin stake) { private void publishBlindVote(Coin stake) {
voteButtonBusyAnimation.play(); voteButtonBusyAnimation.play();
voteButtonInfoLabel.setText(Res.get("dao.blindVote.startPublishing")); voteButtonInfoLabel.setText(Res.get("dao.blindVote.startPublishing"));
myVoteService.publishBlindVote(stake, myVoteServiceFacade.publishBlindVote(stake,
() -> { () -> {
voteButtonBusyAnimation.stop(); voteButtonBusyAnimation.stop();
voteButtonInfoLabel.setText(""); voteButtonInfoLabel.setText("");
@ -270,7 +269,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
if (selectedProposalListItem != null && if (selectedProposalListItem != null &&
proposalDisplay != null && proposalDisplay != null &&
!periodServiceFacade.isTxInPastCycle(selectedProposalListItem.getBallot().getTxId(), !periodServiceFacade.isTxInPastCycle(selectedProposalListItem.getBallot().getTxId(),
stateService.getChainHeight())) { stateServiceFacade.getChainHeight())) {
final Ballot ballot = selectedProposalListItem.getBallot(); final Ballot ballot = selectedProposalListItem.getBallot();
switch (phase) { switch (phase) {
case PROPOSAL: case PROPOSAL:

View file

@ -34,10 +34,10 @@ import bisq.core.dao.consensus.ballot.BallotList;
import bisq.core.dao.consensus.proposal.param.ChangeParamService; import bisq.core.dao.consensus.proposal.param.ChangeParamService;
import bisq.core.dao.consensus.vote.BooleanVote; import bisq.core.dao.consensus.vote.BooleanVote;
import bisq.core.dao.consensus.vote.Vote; import bisq.core.dao.consensus.vote.Vote;
import bisq.core.dao.presentation.myvote.MyVoteService; import bisq.core.dao.presentation.myvote.MyVoteServiceFacade;
import bisq.core.dao.presentation.period.PeriodServiceFacade; import bisq.core.dao.presentation.period.PeriodServiceFacade;
import bisq.core.dao.presentation.proposal.MyBallotListService;
import bisq.core.dao.presentation.proposal.FilteredBallotListService; import bisq.core.dao.presentation.proposal.FilteredBallotListService;
import bisq.core.dao.presentation.proposal.MyBallotListService;
import bisq.core.dao.presentation.state.StateServiceFacade; import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res; import bisq.core.locale.Res;
import bisq.core.user.Preferences; import bisq.core.user.Preferences;
@ -74,7 +74,7 @@ import java.util.stream.Collectors;
@FxmlView @FxmlView
public class MyVotesView extends BaseProposalView { public class MyVotesView extends BaseProposalView {
private final MyVoteService myVoteService; private final MyVoteServiceFacade myVoteServiceFacade;
private final Preferences preferences; private final Preferences preferences;
private final ObservableList<VoteListItem> voteListItems = FXCollections.observableArrayList(); private final ObservableList<VoteListItem> voteListItems = FXCollections.observableArrayList();
@ -97,12 +97,12 @@ public class MyVotesView extends BaseProposalView {
ChangeParamService changeParamService, ChangeParamService changeParamService,
BsqFormatter bsqFormatter, BsqFormatter bsqFormatter,
BSFormatter btcFormatter, BSFormatter btcFormatter,
MyVoteService myVoteService, MyVoteServiceFacade myVoteServiceFacade,
Preferences preferences) { Preferences preferences) {
super(myBallotListService, filteredBallotListService, bsqWalletService, stateService, super(myBallotListService, filteredBallotListService, bsqWalletService, stateService,
periodServiceFacade, changeParamService, bsqFormatter, btcFormatter); periodServiceFacade, changeParamService, bsqFormatter, btcFormatter);
this.myVoteService = myVoteService; this.myVoteServiceFacade = myVoteServiceFacade;
this.preferences = preferences; this.preferences = preferences;
} }
@ -127,8 +127,8 @@ public class MyVotesView extends BaseProposalView {
sortedList.comparatorProperty().bind(votesTableView.comparatorProperty()); sortedList.comparatorProperty().bind(votesTableView.comparatorProperty());
voteListItems.clear(); voteListItems.clear();
List<VoteListItem> items = myVoteService.getMyVoteList().stream() List<VoteListItem> items = myVoteServiceFacade.getMyVoteList().stream()
.map(vote -> new VoteListItem(vote, bsqWalletService, stateService, periodServiceFacade, bsqFormatter)) .map(vote -> new VoteListItem(vote, bsqWalletService, stateServiceFacade, periodServiceFacade, bsqFormatter))
.collect(Collectors.toList()); .collect(Collectors.toList());
voteListItems.addAll(items); voteListItems.addAll(items);
} }

View file

@ -22,11 +22,11 @@ import bisq.desktop.util.BsqFormatter;
import bisq.core.btc.listeners.TxConfidenceListener; import bisq.core.btc.listeners.TxConfidenceListener;
import bisq.core.btc.wallet.BsqWalletService; import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.consensus.myvote.MyVote;
import bisq.core.dao.consensus.state.Block; import bisq.core.dao.consensus.state.Block;
import bisq.core.dao.consensus.state.BlockListener; import bisq.core.dao.consensus.state.BlockListener;
import bisq.core.dao.consensus.state.blockchain.Tx; import bisq.core.dao.consensus.state.blockchain.Tx;
import bisq.core.dao.consensus.state.blockchain.TxOutput; import bisq.core.dao.consensus.state.blockchain.TxOutput;
import bisq.core.dao.presentation.myvote.MyVote;
import bisq.core.dao.presentation.period.PeriodServiceFacade; import bisq.core.dao.presentation.period.PeriodServiceFacade;
import bisq.core.dao.presentation.state.StateServiceFacade; import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res; import bisq.core.locale.Res;