mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
Remove usage of PeriodServiceFacade and ThreadAwareListener
This commit is contained in:
parent
c9a4d54615
commit
7e207d380d
7 changed files with 44 additions and 44 deletions
|
@ -28,12 +28,12 @@ import bisq.desktop.util.BsqFormatter;
|
|||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.consensus.ballot.Ballot;
|
||||
import bisq.core.dao.consensus.period.PeriodService;
|
||||
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.ballot.FilteredBallotListService;
|
||||
import bisq.core.dao.presentation.ballot.MyBallotListService;
|
||||
import bisq.core.dao.presentation.period.PeriodServiceFacade;
|
||||
import bisq.core.dao.presentation.state.StateServiceFacade;
|
||||
import bisq.core.locale.Res;
|
||||
|
||||
|
@ -73,7 +73,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
|
|||
|
||||
protected final MyBallotListService myBallotListService;
|
||||
protected final StateServiceFacade stateServiceFacade;
|
||||
protected final PeriodServiceFacade periodServiceFacade;
|
||||
protected final PeriodService PeriodService;
|
||||
protected final ChangeParamService changeParamService;
|
||||
protected final FilteredBallotListService filteredBallotListService;
|
||||
protected final BsqWalletService bsqWalletService;
|
||||
|
@ -105,7 +105,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
|
|||
FilteredBallotListService filteredBallotListService,
|
||||
BsqWalletService bsqWalletService,
|
||||
StateServiceFacade stateServiceFacade,
|
||||
PeriodServiceFacade periodServiceFacade,
|
||||
PeriodService PeriodService,
|
||||
ChangeParamService changeParamService,
|
||||
BsqFormatter bsqFormatter,
|
||||
BSFormatter btcFormatter) {
|
||||
|
@ -113,7 +113,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
|
|||
this.filteredBallotListService = filteredBallotListService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.stateServiceFacade = stateServiceFacade;
|
||||
this.periodServiceFacade = periodServiceFacade;
|
||||
this.PeriodService = PeriodService;
|
||||
this.changeParamService = changeParamService;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
this.btcFormatter = btcFormatter;
|
||||
|
@ -132,12 +132,12 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
|
|||
|
||||
@Override
|
||||
protected void activate() {
|
||||
phaseSubscription = EasyBind.subscribe(periodServiceFacade.phaseProperty(), this::onPhaseChanged);
|
||||
phaseSubscription = EasyBind.subscribe(PeriodService.phaseProperty(), this::onPhaseChanged);
|
||||
selectedProposalSubscription = EasyBind.subscribe(proposalTableView.getSelectionModel().selectedItemProperty(), this::onSelectProposal);
|
||||
|
||||
periodServiceFacade.phaseProperty().addListener(phaseChangeListener);
|
||||
PeriodService.phaseProperty().addListener(phaseChangeListener);
|
||||
|
||||
onPhaseChanged(periodServiceFacade.phaseProperty().get());
|
||||
onPhaseChanged(PeriodService.phaseProperty().get());
|
||||
|
||||
sortedList.comparatorProperty().bind(proposalTableView.comparatorProperty());
|
||||
|
||||
|
@ -149,7 +149,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
|
|||
phaseSubscription.unsubscribe();
|
||||
selectedProposalSubscription.unsubscribe();
|
||||
|
||||
periodServiceFacade.phaseProperty().removeListener(phaseChangeListener);
|
||||
PeriodService.phaseProperty().removeListener(phaseChangeListener);
|
||||
|
||||
sortedList.comparatorProperty().unbind();
|
||||
|
||||
|
@ -250,7 +250,7 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
|
|||
proposalListItems.setAll(list.stream()
|
||||
.map(ballot -> new ProposalListItem(ballot,
|
||||
myBallotListService,
|
||||
periodServiceFacade,
|
||||
PeriodService,
|
||||
bsqWalletService,
|
||||
stateServiceFacade,
|
||||
bsqFormatter))
|
||||
|
|
|
@ -24,6 +24,7 @@ import bisq.desktop.util.BsqFormatter;
|
|||
import bisq.core.btc.listeners.TxConfidenceListener;
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.consensus.ballot.Ballot;
|
||||
import bisq.core.dao.consensus.period.PeriodService;
|
||||
import bisq.core.dao.consensus.period.Phase;
|
||||
import bisq.core.dao.consensus.state.Block;
|
||||
import bisq.core.dao.consensus.state.BlockListener;
|
||||
|
@ -31,7 +32,6 @@ 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.presentation.ballot.MyBallotListService;
|
||||
import bisq.core.dao.presentation.period.PeriodServiceFacade;
|
||||
import bisq.core.dao.presentation.state.StateServiceFacade;
|
||||
import bisq.core.locale.Res;
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class ProposalListItem implements BlockListener {
|
|||
@Getter
|
||||
private final Ballot ballot;
|
||||
private final MyBallotListService myBallotListService;
|
||||
private final PeriodServiceFacade periodServiceFacade;
|
||||
private final PeriodService PeriodService;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final StateServiceFacade stateServiceFacade;
|
||||
private final BsqFormatter bsqFormatter;
|
||||
|
@ -82,13 +82,13 @@ public class ProposalListItem implements BlockListener {
|
|||
|
||||
ProposalListItem(Ballot ballot,
|
||||
MyBallotListService myBallotListService,
|
||||
PeriodServiceFacade periodServiceFacade,
|
||||
PeriodService PeriodService,
|
||||
BsqWalletService bsqWalletService,
|
||||
StateServiceFacade stateServiceFacade,
|
||||
BsqFormatter bsqFormatter) {
|
||||
this.ballot = ballot;
|
||||
this.myBallotListService = myBallotListService;
|
||||
this.periodServiceFacade = periodServiceFacade;
|
||||
this.PeriodService = PeriodService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.stateServiceFacade = stateServiceFacade;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
|
@ -116,10 +116,10 @@ public class ProposalListItem implements BlockListener {
|
|||
};
|
||||
|
||||
voteResultChangeListener = (observable, oldValue, newValue) -> {
|
||||
applyState(periodServiceFacade.phaseProperty().get(), newValue);
|
||||
applyState(PeriodService.phaseProperty().get(), newValue);
|
||||
};
|
||||
|
||||
periodServiceFacade.phaseProperty().addListener(phaseChangeListener);
|
||||
PeriodService.phaseProperty().addListener(phaseChangeListener);
|
||||
ballot.getVoteResultProperty().addListener(voteResultChangeListener);
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class ProposalListItem implements BlockListener {
|
|||
actionButton.setText("");
|
||||
actionButton.setVisible(false);
|
||||
actionButton.setOnAction(null);
|
||||
final boolean isTxInPastCycle = periodServiceFacade.isTxInPastCycle(ballot.getTxId(),
|
||||
final boolean isTxInPastCycle = PeriodService.isTxInPastCycle(ballot.getTxId(),
|
||||
stateServiceFacade.getChainHeight());
|
||||
switch (phase) {
|
||||
case UNDEFINED:
|
||||
|
@ -253,7 +253,7 @@ public class ProposalListItem implements BlockListener {
|
|||
if (txConfidenceListener != null)
|
||||
bsqWalletService.removeTxConfidenceListener(txConfidenceListener);
|
||||
|
||||
periodServiceFacade.phaseProperty().removeListener(phaseChangeListener);
|
||||
PeriodService.phaseProperty().removeListener(phaseChangeListener);
|
||||
ballot.getVoteResultProperty().removeListener(voteResultChangeListener);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,13 +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.period.PeriodService;
|
||||
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.ballot.FilteredBallotListService;
|
||||
import bisq.core.dao.presentation.ballot.MyBallotListService;
|
||||
import bisq.core.dao.presentation.myvote.MyBlindVoteServiceFacade;
|
||||
import bisq.core.dao.presentation.period.PeriodServiceFacade;
|
||||
import bisq.core.dao.presentation.state.StateServiceFacade;
|
||||
import bisq.core.locale.Res;
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
|
|||
@Inject
|
||||
private ActiveProposalsView(MyBallotListService myBallotListService,
|
||||
FilteredBallotListService filteredBallotListService,
|
||||
PeriodServiceFacade periodServiceFacade,
|
||||
PeriodService PeriodService,
|
||||
MyBlindVoteServiceFacade myBlindVoteServiceFacade,
|
||||
BsqWalletService bsqWalletService,
|
||||
StateServiceFacade stateService,
|
||||
|
@ -98,7 +98,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
|
|||
BSFormatter btcFormatter) {
|
||||
|
||||
super(myBallotListService, filteredBallotListService, bsqWalletService, stateService,
|
||||
periodServiceFacade, changeParamService, bsqFormatter, btcFormatter);
|
||||
PeriodService, changeParamService, bsqFormatter, btcFormatter);
|
||||
this.myBlindVoteServiceFacade = myBlindVoteServiceFacade;
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
|
|||
cancelVoteButton = null;
|
||||
}
|
||||
|
||||
onPhaseChanged(periodServiceFacade.phaseProperty().get());
|
||||
onPhaseChanged(PeriodService.phaseProperty().get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
|
|||
}
|
||||
if (selectedProposalListItem != null &&
|
||||
proposalDisplay != null &&
|
||||
!periodServiceFacade.isTxInPastCycle(selectedProposalListItem.getBallot().getTxId(),
|
||||
!PeriodService.isTxInPastCycle(selectedProposalListItem.getBallot().getTxId(),
|
||||
stateServiceFacade.getChainHeight())) {
|
||||
final Ballot ballot = selectedProposalListItem.getBallot();
|
||||
switch (phase) {
|
||||
|
|
|
@ -23,10 +23,10 @@ import bisq.desktop.util.BSFormatter;
|
|||
import bisq.desktop.util.BsqFormatter;
|
||||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.consensus.period.PeriodService;
|
||||
import bisq.core.dao.consensus.proposal.param.ChangeParamService;
|
||||
import bisq.core.dao.presentation.ballot.FilteredBallotListService;
|
||||
import bisq.core.dao.presentation.ballot.MyBallotListService;
|
||||
import bisq.core.dao.presentation.period.PeriodServiceFacade;
|
||||
import bisq.core.dao.presentation.state.StateServiceFacade;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -41,7 +41,7 @@ public class ClosedProposalsView extends BaseProposalView {
|
|||
@Inject
|
||||
private ClosedProposalsView(MyBallotListService myBallotListService,
|
||||
FilteredBallotListService filteredBallotListService,
|
||||
PeriodServiceFacade periodServiceFacade,
|
||||
PeriodService PeriodService,
|
||||
BsqWalletService bsqWalletService,
|
||||
StateServiceFacade stateService,
|
||||
ChangeParamService changeParamService,
|
||||
|
@ -49,7 +49,7 @@ public class ClosedProposalsView extends BaseProposalView {
|
|||
BSFormatter btcFormatter) {
|
||||
|
||||
super(myBallotListService, filteredBallotListService, bsqWalletService, stateService,
|
||||
periodServiceFacade, changeParamService, bsqFormatter, btcFormatter);
|
||||
PeriodService, changeParamService, bsqFormatter, btcFormatter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,9 +22,9 @@ import bisq.desktop.common.view.FxmlView;
|
|||
import bisq.desktop.components.SeparatedPhaseBars;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
||||
import bisq.core.dao.consensus.period.PeriodService;
|
||||
import bisq.core.dao.consensus.period.PeriodStateChangeListener;
|
||||
import bisq.core.dao.consensus.period.Phase;
|
||||
import bisq.core.dao.presentation.period.PeriodServiceFacade;
|
||||
import bisq.core.locale.Res;
|
||||
|
||||
import bisq.common.UserThread;
|
||||
|
@ -51,7 +51,7 @@ import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
|
|||
public class ProposalDashboardView extends ActivatableView<GridPane, Void> implements PeriodStateChangeListener {
|
||||
|
||||
private List<SeparatedPhaseBars.SeparatedPhaseBarsItem> phaseBarsItems;
|
||||
private final PeriodServiceFacade periodServiceFacade;
|
||||
private final PeriodService PeriodService;
|
||||
private Phase currentPhase;
|
||||
private Subscription phaseSubscription;
|
||||
private GridPane gridPane;
|
||||
|
@ -64,8 +64,8 @@ public class ProposalDashboardView extends ActivatableView<GridPane, Void> imple
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private ProposalDashboardView(PeriodServiceFacade periodServiceFacade) {
|
||||
this.periodServiceFacade = periodServiceFacade;
|
||||
private ProposalDashboardView(PeriodService PeriodService) {
|
||||
this.PeriodService = PeriodService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,7 +111,7 @@ public class ProposalDashboardView extends ActivatableView<GridPane, Void> imple
|
|||
protected void activate() {
|
||||
super.activate();
|
||||
|
||||
phaseSubscription = EasyBind.subscribe(periodServiceFacade.phaseProperty(), phase -> {
|
||||
phaseSubscription = EasyBind.subscribe(PeriodService.phaseProperty(), phase -> {
|
||||
if (!phase.equals(this.currentPhase)) {
|
||||
this.currentPhase = phase;
|
||||
}
|
||||
|
@ -124,16 +124,16 @@ public class ProposalDashboardView extends ActivatableView<GridPane, Void> imple
|
|||
});
|
||||
|
||||
});
|
||||
periodServiceFacade.addPeriodStateChangeListener(this);
|
||||
PeriodService.addPeriodStateChangeListener(this);
|
||||
|
||||
// We need to delay as otherwise the periodService has not been updated yet.
|
||||
UserThread.execute(() -> onPreParserChainHeightChanged(periodServiceFacade.getChainHeight()));
|
||||
UserThread.execute(() -> onPreParserChainHeightChanged(PeriodService.getChainHeight()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
super.deactivate();
|
||||
periodServiceFacade.removePeriodStateChangeListener(this);
|
||||
PeriodService.removePeriodStateChangeListener(this);
|
||||
phaseSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
|
@ -142,9 +142,9 @@ public class ProposalDashboardView extends ActivatableView<GridPane, Void> imple
|
|||
if (height > 0) {
|
||||
separatedPhaseBars.updateWidth();
|
||||
phaseBarsItems.forEach(item -> {
|
||||
int firstBlock = periodServiceFacade.getFirstBlockOfPhase(height, item.getPhase());
|
||||
int lastBlock = periodServiceFacade.getLastBlockOfPhase(height, item.getPhase());
|
||||
final int duration = periodServiceFacade.getDurationForPhase(item.getPhase(), periodServiceFacade.getChainHeight());
|
||||
int firstBlock = PeriodService.getFirstBlockOfPhase(height, item.getPhase());
|
||||
int lastBlock = PeriodService.getLastBlockOfPhase(height, item.getPhase());
|
||||
final int duration = PeriodService.getDurationForPhase(item.getPhase(), PeriodService.getChainHeight());
|
||||
item.setPeriodRange(firstBlock, lastBlock, duration);
|
||||
double progress = 0;
|
||||
if (height >= firstBlock && height <= lastBlock) {
|
||||
|
|
|
@ -31,13 +31,13 @@ import bisq.desktop.util.Layout;
|
|||
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.consensus.ballot.BallotList;
|
||||
import bisq.core.dao.consensus.period.PeriodService;
|
||||
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.ballot.FilteredBallotListService;
|
||||
import bisq.core.dao.presentation.ballot.MyBallotListService;
|
||||
import bisq.core.dao.presentation.myvote.MyBlindVoteServiceFacade;
|
||||
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,7 +93,7 @@ public class MyVotesView extends BaseProposalView {
|
|||
FilteredBallotListService filteredBallotListService,
|
||||
BsqWalletService bsqWalletService,
|
||||
StateServiceFacade stateService,
|
||||
PeriodServiceFacade periodServiceFacade,
|
||||
PeriodService PeriodService,
|
||||
ChangeParamService changeParamService,
|
||||
BsqFormatter bsqFormatter,
|
||||
BSFormatter btcFormatter,
|
||||
|
@ -101,7 +101,7 @@ public class MyVotesView extends BaseProposalView {
|
|||
Preferences preferences) {
|
||||
|
||||
super(myBallotListService, filteredBallotListService, bsqWalletService, stateService,
|
||||
periodServiceFacade, changeParamService, bsqFormatter, btcFormatter);
|
||||
PeriodService, changeParamService, bsqFormatter, btcFormatter);
|
||||
this.myBlindVoteServiceFacade = myBlindVoteServiceFacade;
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class MyVotesView extends BaseProposalView {
|
|||
|
||||
voteListItems.clear();
|
||||
List<VoteListItem> items = myBlindVoteServiceFacade.getMyVoteList().stream()
|
||||
.map(vote -> new VoteListItem(vote, bsqWalletService, stateServiceFacade, periodServiceFacade, bsqFormatter))
|
||||
.map(vote -> new VoteListItem(vote, bsqWalletService, stateServiceFacade, PeriodService, bsqFormatter))
|
||||
.collect(Collectors.toList());
|
||||
voteListItems.addAll(items);
|
||||
}
|
||||
|
|
|
@ -23,11 +23,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.period.PeriodService;
|
||||
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.period.PeriodServiceFacade;
|
||||
import bisq.core.dao.presentation.state.StateServiceFacade;
|
||||
import bisq.core.locale.Res;
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class VoteListItem implements BlockListener {
|
|||
private final MyVote myVote;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final StateServiceFacade stateServiceFacade;
|
||||
private final PeriodServiceFacade periodServiceFacade;
|
||||
private final PeriodService PeriodService;
|
||||
private final BsqFormatter bsqFormatter;
|
||||
private final ChangeListener<Number> chainHeightListener;
|
||||
@Getter
|
||||
|
@ -78,12 +78,12 @@ public class VoteListItem implements BlockListener {
|
|||
VoteListItem(MyVote myVote,
|
||||
BsqWalletService bsqWalletService,
|
||||
StateServiceFacade stateServiceFacade,
|
||||
PeriodServiceFacade periodServiceFacade,
|
||||
PeriodService PeriodService,
|
||||
BsqFormatter bsqFormatter) {
|
||||
this.myVote = myVote;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.stateServiceFacade = stateServiceFacade;
|
||||
this.periodServiceFacade = periodServiceFacade;
|
||||
this.PeriodService = PeriodService;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
|
||||
txConfidenceIndicator = new TxConfidenceIndicator();
|
||||
|
|
Loading…
Add table
Reference in a new issue