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.param.ChangeParamService;
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.MyBallotListService;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
@ -72,7 +72,7 @@ import java.util.stream.Collectors;
public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
protected final MyBallotListService myBallotListService;
protected final StateServiceFacade stateService;
protected final StateServiceFacade stateServiceFacade;
protected final PeriodServiceFacade periodServiceFacade;
protected final ChangeParamService changeParamService;
protected final FilteredBallotListService filteredBallotListService;
@ -104,7 +104,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
protected BaseProposalView(MyBallotListService myBallotListService,
FilteredBallotListService filteredBallotListService,
BsqWalletService bsqWalletService,
StateServiceFacade stateService,
StateServiceFacade stateServiceFacade,
PeriodServiceFacade periodServiceFacade,
ChangeParamService changeParamService,
BsqFormatter bsqFormatter,
@ -112,7 +112,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
this.myBallotListService = myBallotListService;
this.filteredBallotListService = filteredBallotListService;
this.bsqWalletService = bsqWalletService;
this.stateService = stateService;
this.stateServiceFacade = stateServiceFacade;
this.periodServiceFacade = periodServiceFacade;
this.changeParamService = changeParamService;
this.bsqFormatter = bsqFormatter;
@ -252,7 +252,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
myBallotListService,
periodServiceFacade,
bsqWalletService,
stateService,
stateServiceFacade,
bsqFormatter))
.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.BsqWalletService;
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.proposal.param.ChangeParamService;
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.proposal.MyBallotListService;
import bisq.core.dao.presentation.proposal.FilteredBallotListService;
import bisq.core.dao.presentation.proposal.MyBallotListService;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
@ -74,7 +73,7 @@ import static bisq.desktop.util.FormBuilder.*;
@FxmlView
public class ActiveProposalsView extends BaseProposalView implements BsqBalanceListener {
private final MyVoteService myVoteService;
private final MyVoteServiceFacade myVoteServiceFacade;
private Button removeButton, acceptButton, rejectButton, cancelVoteButton, voteButton;
private InputTextField stakeInputTextField;
@ -91,7 +90,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
private ActiveProposalsView(MyBallotListService myBallotListService,
FilteredBallotListService filteredBallotListService,
PeriodServiceFacade periodServiceFacade,
MyVoteService myVoteService,
MyVoteServiceFacade myVoteServiceFacade,
BsqWalletService bsqWalletService,
StateServiceFacade stateService,
ChangeParamService changeParamService,
@ -100,7 +99,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
super(myBallotListService, filteredBallotListService, bsqWalletService, stateService,
periodServiceFacade, changeParamService, bsqFormatter, btcFormatter);
this.myVoteService = myVoteService;
this.myVoteServiceFacade = myVoteServiceFacade;
}
@Override
@ -129,11 +128,11 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
voteButton.setOnAction(e -> {
// TODO verify stake
Coin stake = bsqFormatter.parseToCoin(stakeInputTextField.getText());
final Coin fee = BlindVoteConsensus.getFee(changeParamService, stateService.getChainHeight());
final Coin blindVoteFee = myVoteServiceFacade.getBlindVoteFee();
Transaction dummyTx = null;
try {
// We create a tx with dummy opreturn data to get the mining fee for confirmation popup
dummyTx = myVoteService.getBlindVoteTx(stake, fee, new byte[22]);
// We create a dummy tx to get the mining blindVoteFee for confirmation popup
dummyTx = myVoteServiceFacade.getDummyBlindVoteTx(stake, blindVoteFee);
} catch (InsufficientMoneyException | WalletException | TransactionVerificationException exception) {
new Popup<>().warning(exception.toString()).show();
}
@ -141,7 +140,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
if (dummyTx != null) {
Coin miningFee = dummyTx.getFee();
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));
}
});
@ -151,7 +150,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
private void publishBlindVote(Coin stake) {
voteButtonBusyAnimation.play();
voteButtonInfoLabel.setText(Res.get("dao.blindVote.startPublishing"));
myVoteService.publishBlindVote(stake,
myVoteServiceFacade.publishBlindVote(stake,
() -> {
voteButtonBusyAnimation.stop();
voteButtonInfoLabel.setText("");
@ -270,7 +269,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
if (selectedProposalListItem != null &&
proposalDisplay != null &&
!periodServiceFacade.isTxInPastCycle(selectedProposalListItem.getBallot().getTxId(),
stateService.getChainHeight())) {
stateServiceFacade.getChainHeight())) {
final Ballot ballot = selectedProposalListItem.getBallot();
switch (phase) {
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.vote.BooleanVote;
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.proposal.MyBallotListService;
import bisq.core.dao.presentation.proposal.FilteredBallotListService;
import bisq.core.dao.presentation.proposal.MyBallotListService;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
import bisq.core.user.Preferences;
@ -74,7 +74,7 @@ import java.util.stream.Collectors;
@FxmlView
public class MyVotesView extends BaseProposalView {
private final MyVoteService myVoteService;
private final MyVoteServiceFacade myVoteServiceFacade;
private final Preferences preferences;
private final ObservableList<VoteListItem> voteListItems = FXCollections.observableArrayList();
@ -97,12 +97,12 @@ public class MyVotesView extends BaseProposalView {
ChangeParamService changeParamService,
BsqFormatter bsqFormatter,
BSFormatter btcFormatter,
MyVoteService myVoteService,
MyVoteServiceFacade myVoteServiceFacade,
Preferences preferences) {
super(myBallotListService, filteredBallotListService, bsqWalletService, stateService,
periodServiceFacade, changeParamService, bsqFormatter, btcFormatter);
this.myVoteService = myVoteService;
this.myVoteServiceFacade = myVoteServiceFacade;
this.preferences = preferences;
}
@ -127,8 +127,8 @@ public class MyVotesView extends BaseProposalView {
sortedList.comparatorProperty().bind(votesTableView.comparatorProperty());
voteListItems.clear();
List<VoteListItem> items = myVoteService.getMyVoteList().stream()
.map(vote -> new VoteListItem(vote, bsqWalletService, stateService, periodServiceFacade, bsqFormatter))
List<VoteListItem> items = myVoteServiceFacade.getMyVoteList().stream()
.map(vote -> new VoteListItem(vote, bsqWalletService, stateServiceFacade, periodServiceFacade, bsqFormatter))
.collect(Collectors.toList());
voteListItems.addAll(items);
}

View file

@ -22,11 +22,11 @@ import bisq.desktop.util.BsqFormatter;
import bisq.core.btc.listeners.TxConfidenceListener;
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.BlockListener;
import bisq.core.dao.consensus.state.blockchain.Tx;
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.state.StateServiceFacade;
import bisq.core.locale.Res;