Merge branch 'rpc_thread' into voting

This commit is contained in:
Manfred Karrer 2018-04-21 22:21:04 -05:00
commit 930573a6dd
No known key found for this signature in database
GPG key ID: 401250966A6B2C46
13 changed files with 140 additions and 140 deletions

View file

@ -28,13 +28,13 @@ 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.dao.consensus.state.StateService;
import bisq.core.dao.consensus.ballot.FilteredBallotListService;
import bisq.core.dao.consensus.ballot.MyBallotListService;
import bisq.core.locale.Res;
import javax.inject.Inject;
@ -72,8 +72,8 @@ import java.util.stream.Collectors;
public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
protected final MyBallotListService myBallotListService;
protected final StateServiceFacade stateServiceFacade;
protected final PeriodServiceFacade periodServiceFacade;
protected final StateService stateService;
protected final PeriodService PeriodService;
protected final ChangeParamService changeParamService;
protected final FilteredBallotListService filteredBallotListService;
protected final BsqWalletService bsqWalletService;
@ -104,16 +104,16 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
protected BaseProposalView(MyBallotListService myBallotListService,
FilteredBallotListService filteredBallotListService,
BsqWalletService bsqWalletService,
StateServiceFacade stateServiceFacade,
PeriodServiceFacade periodServiceFacade,
StateService stateService,
PeriodService PeriodService,
ChangeParamService changeParamService,
BsqFormatter bsqFormatter,
BSFormatter btcFormatter) {
this.myBallotListService = myBallotListService;
this.filteredBallotListService = filteredBallotListService;
this.bsqWalletService = bsqWalletService;
this.stateServiceFacade = stateServiceFacade;
this.periodServiceFacade = periodServiceFacade;
this.stateService = stateService;
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,9 +250,9 @@ public abstract class BaseProposalView extends ActivatableView<GridPane, Void> {
proposalListItems.setAll(list.stream()
.map(ballot -> new ProposalListItem(ballot,
myBallotListService,
periodServiceFacade,
PeriodService,
bsqWalletService,
stateServiceFacade,
stateService,
bsqFormatter))
.collect(Collectors.toSet()));

View file

@ -24,15 +24,15 @@ 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;
import bisq.core.dao.consensus.state.StateService;
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.dao.consensus.ballot.MyBallotListService;
import bisq.core.locale.Res;
import org.bitcoinj.core.Transaction;
@ -59,9 +59,9 @@ 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 StateService stateService;
private final BsqFormatter bsqFormatter;
private final ChangeListener<Number> chainHeightListener;
private final ChangeListener<Vote> voteResultChangeListener;
@ -82,15 +82,15 @@ public class ProposalListItem implements BlockListener {
ProposalListItem(Ballot ballot,
MyBallotListService myBallotListService,
PeriodServiceFacade periodServiceFacade,
PeriodService PeriodService,
BsqWalletService bsqWalletService,
StateServiceFacade stateServiceFacade,
StateService stateService,
BsqFormatter bsqFormatter) {
this.ballot = ballot;
this.myBallotListService = myBallotListService;
this.periodServiceFacade = periodServiceFacade;
this.PeriodService = PeriodService;
this.bsqWalletService = bsqWalletService;
this.stateServiceFacade = stateServiceFacade;
this.stateService = stateService;
this.bsqFormatter = bsqFormatter;
@ -109,17 +109,17 @@ public class ProposalListItem implements BlockListener {
bsqWalletService.getChainHeightProperty().addListener(chainHeightListener);
setupConfidence();
stateServiceFacade.addBlockListener(this);
stateService.addBlockListener(this);
phaseChangeListener = (observable, oldValue, newValue) -> {
applyState(newValue, ballot.getVote());
};
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,8 +128,8 @@ public class ProposalListItem implements BlockListener {
actionButton.setText("");
actionButton.setVisible(false);
actionButton.setOnAction(null);
final boolean isTxInPastCycle = periodServiceFacade.isTxInPastCycle(ballot.getTxId(),
stateServiceFacade.getChainHeight());
final boolean isTxInPastCycle = PeriodService.isTxInPastCycle(ballot.getTxId(),
stateService.getChainHeight());
switch (phase) {
case UNDEFINED:
log.error("invalid state UNDEFINED");
@ -204,7 +204,7 @@ public class ProposalListItem implements BlockListener {
private void setupConfidence() {
final Tx tx = stateServiceFacade.getTxMap().get(ballot.getProposal().getTxId());
final Tx tx = stateService.getTxMap().get(ballot.getProposal().getTxId());
if (tx != null) {
final String txId = tx.getId();
@ -248,12 +248,12 @@ public class ProposalListItem implements BlockListener {
}
public void cleanup() {
stateServiceFacade.removeBlockListener(this);
stateService.removeBlockListener(this);
bsqWalletService.getChainHeightProperty().removeListener(chainHeightListener);
if (txConfidenceListener != null)
bsqWalletService.removeTxConfidenceListener(txConfidenceListener);
periodServiceFacade.phaseProperty().removeListener(phaseChangeListener);
PeriodService.phaseProperty().removeListener(phaseChangeListener);
ballot.getVoteResultProperty().removeListener(voteResultChangeListener);
}

View file

@ -34,14 +34,14 @@ 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.ballot.FilteredBallotListService;
import bisq.core.dao.consensus.ballot.MyBallotListService;
import bisq.core.dao.consensus.myvote.MyBlindVoteService;
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.state.StateService;
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;
import bisq.common.util.Tuple2;
@ -73,7 +73,7 @@ import static bisq.desktop.util.FormBuilder.*;
@FxmlView
public class ActiveProposalsView extends BaseProposalView implements BsqBalanceListener {
private final MyBlindVoteServiceFacade myBlindVoteServiceFacade;
private final MyBlindVoteService myBlindVoteService;
private Button removeButton, acceptButton, rejectButton, cancelVoteButton, voteButton;
private InputTextField stakeInputTextField;
@ -89,17 +89,17 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
@Inject
private ActiveProposalsView(MyBallotListService myBallotListService,
FilteredBallotListService filteredBallotListService,
PeriodServiceFacade periodServiceFacade,
MyBlindVoteServiceFacade myBlindVoteServiceFacade,
PeriodService PeriodService,
MyBlindVoteService myBlindVoteService,
BsqWalletService bsqWalletService,
StateServiceFacade stateService,
StateService stateService,
ChangeParamService changeParamService,
BsqFormatter bsqFormatter,
BSFormatter btcFormatter) {
super(myBallotListService, filteredBallotListService, bsqWalletService, stateService,
periodServiceFacade, changeParamService, bsqFormatter, btcFormatter);
this.myBlindVoteServiceFacade = myBlindVoteServiceFacade;
PeriodService, changeParamService, bsqFormatter, btcFormatter);
this.myBlindVoteService = myBlindVoteService;
}
@Override
@ -128,11 +128,11 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
voteButton.setOnAction(e -> {
// TODO verify stake
Coin stake = bsqFormatter.parseToCoin(stakeInputTextField.getText());
final Coin blindVoteFee = myBlindVoteServiceFacade.getBlindVoteFee();
final Coin blindVoteFee = myBlindVoteService.getBlindVoteFee();
Transaction dummyTx = null;
try {
// We create a dummy tx to get the mining blindVoteFee for confirmation popup
dummyTx = myBlindVoteServiceFacade.getDummyBlindVoteTx(stake, blindVoteFee);
dummyTx = myBlindVoteService.getDummyBlindVoteTx(stake, blindVoteFee);
} catch (InsufficientMoneyException | WalletException | TransactionVerificationException exception) {
new Popup<>().warning(exception.toString()).show();
}
@ -150,7 +150,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
private void publishBlindVote(Coin stake) {
voteButtonBusyAnimation.play();
voteButtonInfoLabel.setText(Res.get("dao.blindVote.startPublishing"));
myBlindVoteServiceFacade.publishBlindVote(stake,
myBlindVoteService.publishBlindVote(stake,
() -> {
voteButtonBusyAnimation.stop();
voteButtonInfoLabel.setText("");
@ -235,7 +235,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
cancelVoteButton = null;
}
onPhaseChanged(periodServiceFacade.phaseProperty().get());
onPhaseChanged(PeriodService.phaseProperty().get());
}
}
@ -268,8 +268,8 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
}
if (selectedProposalListItem != null &&
proposalDisplay != null &&
!periodServiceFacade.isTxInPastCycle(selectedProposalListItem.getBallot().getTxId(),
stateServiceFacade.getChainHeight())) {
!PeriodService.isTxInPastCycle(selectedProposalListItem.getBallot().getTxId(),
stateService.getChainHeight())) {
final Ballot ballot = selectedProposalListItem.getBallot();
switch (phase) {
case PROPOSAL:

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.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 bisq.core.dao.consensus.state.StateService;
import bisq.core.dao.consensus.ballot.FilteredBallotListService;
import bisq.core.dao.consensus.ballot.MyBallotListService;
import javax.inject.Inject;
@ -41,15 +41,15 @@ public class ClosedProposalsView extends BaseProposalView {
@Inject
private ClosedProposalsView(MyBallotListService myBallotListService,
FilteredBallotListService filteredBallotListService,
PeriodServiceFacade periodServiceFacade,
PeriodService PeriodService,
BsqWalletService bsqWalletService,
StateServiceFacade stateService,
StateService stateService,
ChangeParamService changeParamService,
BsqFormatter bsqFormatter,
BSFormatter btcFormatter) {
super(myBallotListService, filteredBallotListService, bsqWalletService, stateService,
periodServiceFacade, changeParamService, bsqFormatter, btcFormatter);
PeriodService, changeParamService, bsqFormatter, btcFormatter);
}
@Override

View file

@ -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;
@ -46,12 +46,12 @@ import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
// We use here PeriodStateChangeListener because we are interested in period changes not in the result of a completed
// block. The event from the PeriodStateChangeListener is sent before parsing starts.
// The event from the StateServiceFacade.Listener would notify after parsing a new block.
// The event from the StateService.Listener would notify after parsing a new block.
@FxmlView
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) {

View file

@ -36,10 +36,10 @@ import bisq.core.dao.consensus.ballot.Ballot;
import bisq.core.dao.consensus.proposal.ProposalConsensus;
import bisq.core.dao.consensus.proposal.ProposalType;
import bisq.core.dao.consensus.proposal.param.ChangeParamService;
import bisq.core.dao.presentation.ballot.CompensationBallotFactory;
import bisq.core.dao.presentation.ballot.GenericBallotFactory;
import bisq.core.dao.presentation.ballot.MyBallotListService;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.dao.consensus.state.StateService;
import bisq.core.dao.consensus.ballot.CompensationBallotFactory;
import bisq.core.dao.consensus.ballot.GenericBallotFactory;
import bisq.core.dao.consensus.ballot.MyBallotListService;
import bisq.core.locale.Res;
import bisq.core.provider.fee.FeeService;
@ -86,7 +86,7 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> {
private final MyBallotListService myBallotListService;
private final CompensationBallotFactory compensationBallotFactory;
private final GenericBallotFactory genericBallotFactory;
private final StateServiceFacade stateService;
private final StateService stateService;
private final ChangeParamService changeParamService;
private final BSFormatter btcFormatter;
private final BsqFormatter bsqFormatter;
@ -107,7 +107,7 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> {
MyBallotListService myBallotListService,
CompensationBallotFactory compensationBallotFactory,
GenericBallotFactory genericBallotFactory,
StateServiceFacade stateService,
StateService stateService,
ChangeParamService changeParamService,
BSFormatter btcFormatter,
BsqFormatter bsqFormatter) {

View file

@ -31,14 +31,14 @@ import bisq.desktop.util.Layout;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.dao.consensus.ballot.BallotList;
import bisq.core.dao.consensus.ballot.FilteredBallotListService;
import bisq.core.dao.consensus.ballot.MyBallotListService;
import bisq.core.dao.consensus.myvote.MyBlindVoteService;
import bisq.core.dao.consensus.period.PeriodService;
import bisq.core.dao.consensus.proposal.param.ChangeParamService;
import bisq.core.dao.consensus.state.StateService;
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;
@ -74,7 +74,7 @@ import java.util.stream.Collectors;
@FxmlView
public class MyVotesView extends BaseProposalView {
private final MyBlindVoteServiceFacade myBlindVoteServiceFacade;
private final MyBlindVoteService myBlindVoteService;
private final Preferences preferences;
private final ObservableList<VoteListItem> voteListItems = FXCollections.observableArrayList();
@ -92,17 +92,17 @@ public class MyVotesView extends BaseProposalView {
private MyVotesView(MyBallotListService myBallotListService,
FilteredBallotListService filteredBallotListService,
BsqWalletService bsqWalletService,
StateServiceFacade stateService,
PeriodServiceFacade periodServiceFacade,
StateService stateService,
PeriodService PeriodService,
ChangeParamService changeParamService,
BsqFormatter bsqFormatter,
BSFormatter btcFormatter,
MyBlindVoteServiceFacade myBlindVoteServiceFacade,
MyBlindVoteService myBlindVoteService,
Preferences preferences) {
super(myBallotListService, filteredBallotListService, bsqWalletService, stateService,
periodServiceFacade, changeParamService, bsqFormatter, btcFormatter);
this.myBlindVoteServiceFacade = myBlindVoteServiceFacade;
PeriodService, changeParamService, bsqFormatter, btcFormatter);
this.myBlindVoteService = myBlindVoteService;
this.preferences = preferences;
}
@ -127,8 +127,8 @@ public class MyVotesView extends BaseProposalView {
sortedList.comparatorProperty().bind(votesTableView.comparatorProperty());
voteListItems.clear();
List<VoteListItem> items = myBlindVoteServiceFacade.getMyVoteList().stream()
.map(vote -> new VoteListItem(vote, bsqWalletService, stateServiceFacade, periodServiceFacade, bsqFormatter))
List<VoteListItem> items = myBlindVoteService.getMyVoteList().stream()
.map(vote -> new VoteListItem(vote, bsqWalletService, stateService, PeriodService, bsqFormatter))
.collect(Collectors.toList());
voteListItems.addAll(items);
}

View file

@ -23,12 +23,12 @@ 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.StateService;
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;
import org.bitcoinj.core.Coin;
@ -56,8 +56,8 @@ public class VoteListItem implements BlockListener {
@Getter
private final MyVote myVote;
private final BsqWalletService bsqWalletService;
private final StateServiceFacade stateServiceFacade;
private final PeriodServiceFacade periodServiceFacade;
private final StateService stateService;
private final PeriodService PeriodService;
private final BsqFormatter bsqFormatter;
private final ChangeListener<Number> chainHeightListener;
@Getter
@ -77,13 +77,13 @@ public class VoteListItem implements BlockListener {
VoteListItem(MyVote myVote,
BsqWalletService bsqWalletService,
StateServiceFacade stateServiceFacade,
PeriodServiceFacade periodServiceFacade,
StateService stateService,
PeriodService PeriodService,
BsqFormatter bsqFormatter) {
this.myVote = myVote;
this.bsqWalletService = bsqWalletService;
this.stateServiceFacade = stateServiceFacade;
this.periodServiceFacade = periodServiceFacade;
this.stateService = stateService;
this.PeriodService = PeriodService;
this.bsqFormatter = bsqFormatter;
txConfidenceIndicator = new TxConfidenceIndicator();
@ -92,7 +92,7 @@ public class VoteListItem implements BlockListener {
txConfidenceIndicator.setProgress(-1);
txConfidenceIndicator.setPrefSize(24, 24);
txConfidenceIndicator.setTooltip(tooltip);
stateServiceFacade.addBlockListener(this);
stateService.addBlockListener(this);
chainHeightListener = (observable, oldValue, newValue) -> setupConfidence();
bsqWalletService.getChainHeightProperty().addListener(chainHeightListener);
@ -114,7 +114,7 @@ public class VoteListItem implements BlockListener {
private void setupConfidence() {
calculateStake();
final Tx tx = stateServiceFacade.getTxMap().get(myVote.getBlindVote().getTxId());
final Tx tx = stateService.getTxMap().get(myVote.getBlindVote().getTxId());
if (tx != null) {
final String txId = tx.getId();
@ -153,7 +153,7 @@ public class VoteListItem implements BlockListener {
private void calculateStake() {
if (stake == 0) {
String txId = myVote.getTxId();
stake = stateServiceFacade.getUnspentBlindVoteStakeTxOutputs().stream()
stake = stateService.getUnspentBlindVoteStakeTxOutputs().stream()
.filter(txOutput -> txOutput.getTxId().equals(txId))
.filter(txOutput -> txOutput.getIndex() == 0)
.mapToLong(TxOutput::getValue)
@ -171,7 +171,7 @@ public class VoteListItem implements BlockListener {
public void cleanup() {
bsqWalletService.getChainHeightProperty().removeListener(chainHeightListener);
stateServiceFacade.removeBlockListener(this);
stateService.removeBlockListener(this);
if (txConfidenceListener != null)
bsqWalletService.removeTxConfidenceListener(txConfidenceListener);
}

View file

@ -28,7 +28,7 @@ import bisq.desktop.util.Layout;
import bisq.core.dao.consensus.state.Block;
import bisq.core.dao.consensus.state.BlockListener;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.dao.consensus.state.StateService;
import bisq.core.locale.Res;
import bisq.core.monetary.Altcoin;
import bisq.core.monetary.Price;
@ -60,7 +60,7 @@ import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
public class BsqDashboardView extends ActivatableView<GridPane, Void> implements BlockListener {
private final BsqBalanceUtil bsqBalanceUtil;
private final StateServiceFacade stateServiceFacade;
private final StateService stateService;
private final PriceFeedService priceFeedService;
private final Preferences preferences;
private final BsqFormatter bsqFormatter;
@ -79,12 +79,12 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
@Inject
private BsqDashboardView(BsqBalanceUtil bsqBalanceUtil,
StateServiceFacade stateServiceFacade,
StateService stateService,
PriceFeedService priceFeedService,
Preferences preferences,
BsqFormatter bsqFormatter) {
this.bsqBalanceUtil = bsqBalanceUtil;
this.stateServiceFacade = stateServiceFacade;
this.stateService = stateService;
this.priceFeedService = priceFeedService;
this.preferences = preferences;
this.bsqFormatter = bsqFormatter;
@ -97,13 +97,13 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
addTitledGroupBg(root, ++gridRow, 11, Res.get("dao.wallet.dashboard.statistics"), Layout.GROUP_DISTANCE);
addLabelTextField(root, gridRow, Res.get("dao.wallet.dashboard.genesisBlockHeight"),
String.valueOf(stateServiceFacade.getGenesisBlockHeight()), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
String.valueOf(stateService.getGenesisBlockHeight()), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
Label label = new AutoTooltipLabel(Res.get("dao.wallet.dashboard.genesisTxId"));
GridPane.setRowIndex(label, ++gridRow);
root.getChildren().add(label);
hyperlinkWithIcon = new HyperlinkWithIcon(stateServiceFacade.getGenesisTxId(), AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", stateServiceFacade.getGenesisTxId())));
hyperlinkWithIcon = new HyperlinkWithIcon(stateService.getGenesisTxId(), AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon.setTooltip(new Tooltip(Res.get("tooltip.openBlockchainForTx", stateService.getGenesisTxId())));
GridPane.setRowIndex(hyperlinkWithIcon, gridRow);
GridPane.setColumnIndex(hyperlinkWithIcon, 1);
GridPane.setMargin(hyperlinkWithIcon, new Insets(0, 0, 0, -4));
@ -129,10 +129,10 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
protected void activate() {
bsqBalanceUtil.activate();
stateServiceFacade.addBlockListener(this);
stateService.addBlockListener(this);
priceFeedService.updateCounterProperty().addListener(priceChangeListener);
hyperlinkWithIcon.setOnAction(event -> GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + stateServiceFacade.getGenesisTxId()));
hyperlinkWithIcon.setOnAction(event -> GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + stateService.getGenesisTxId()));
updateWithBsqBlockChainData();
updatePrice();
@ -141,14 +141,14 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
@Override
protected void deactivate() {
bsqBalanceUtil.deactivate();
stateServiceFacade.addBlockListener(this);
stateService.addBlockListener(this);
priceFeedService.updateCounterProperty().removeListener(priceChangeListener);
hyperlinkWithIcon.setOnAction(null);
}
///////////////////////////////////////////////////////////////////////////////////////////
// StateServiceFacade.Listener
// StateService.Listener
///////////////////////////////////////////////////////////////////////////////////////////
@Override
@ -157,25 +157,25 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
}
private void updateWithBsqBlockChainData() {
final Coin issuedAmountFromGenesis = stateServiceFacade.getGenesisTotalSupply();
final Coin issuedAmountFromGenesis = stateService.getGenesisTotalSupply();
genesisIssueAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(issuedAmountFromGenesis));
final Coin issuedAmountFromCompRequests = Coin.valueOf(stateServiceFacade.getTotalIssuedAmountFromCompRequests());
final Coin issuedAmountFromCompRequests = Coin.valueOf(stateService.getTotalIssuedAmountFromCompRequests());
compRequestIssueAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(issuedAmountFromCompRequests));
final Coin burntFee = Coin.valueOf(stateServiceFacade.getTotalBurntFee());
final Coin burntFee = Coin.valueOf(stateService.getTotalBurntFee());
final Coin availableAmount = issuedAmountFromGenesis.add(issuedAmountFromCompRequests).subtract(burntFee);
availableAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(availableAmount));
burntAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(burntFee));
allTxTextField.setText(String.valueOf(stateServiceFacade.getTxs().size()));
utxoTextField.setText(String.valueOf(stateServiceFacade.getUnspentTxOutputs().size()));
allTxTextField.setText(String.valueOf(stateService.getTxs().size()));
utxoTextField.setText(String.valueOf(stateService.getUnspentTxOutputs().size()));
//spentTxTextField.setText(String.valueOf(stateService.getSpentTxOutputs().size()));
burntTxTextField.setText(String.valueOf(stateServiceFacade.getFeeTxs().size()));
burntTxTextField.setText(String.valueOf(stateService.getFeeTxs().size()));
}
private void updatePrice() {
final Coin issuedAmount = stateServiceFacade.getGenesisTotalSupply();
final Coin issuedAmount = stateService.getGenesisTotalSupply();
final MarketPrice bsqMarketPrice = priceFeedService.getMarketPrice("BSQ");
if (bsqMarketPrice != null) {
long bsqPrice = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(bsqMarketPrice.getPrice(), Altcoin.SMALLEST_UNIT_EXPONENT));

View file

@ -25,9 +25,9 @@ import bisq.core.btc.listeners.TxConfidenceListener;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.btc.wallet.WalletService;
import bisq.core.dao.consensus.state.StateService;
import bisq.core.dao.consensus.state.blockchain.Tx;
import bisq.core.dao.consensus.state.blockchain.TxType;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
import org.bitcoinj.core.Coin;
@ -51,7 +51,7 @@ class BsqTxListItem {
private final Optional<Tx> optionalTx;
private final BsqWalletService bsqWalletService;
private final BtcWalletService btcWalletService;
private final StateServiceFacade stateService;
private final StateService stateService;
private final BsqFormatter bsqFormatter;
private final Date date;
private final String txId;
@ -71,7 +71,7 @@ class BsqTxListItem {
Optional<Tx> optionalTx,
BsqWalletService bsqWalletService,
BtcWalletService btcWalletService,
StateServiceFacade stateService,
StateService stateService,
boolean isBurnedBsqTx,
Date date,
BsqFormatter bsqFormatter) {

View file

@ -34,9 +34,9 @@ import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.consensus.state.Block;
import bisq.core.dao.consensus.state.BlockListener;
import bisq.core.dao.consensus.state.StateService;
import bisq.core.dao.consensus.state.blockchain.Tx;
import bisq.core.dao.consensus.state.blockchain.TxType;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
import bisq.core.user.Preferences;
@ -88,7 +88,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
private final BsqFormatter bsqFormatter;
private final BsqWalletService bsqWalletService;
private final StateServiceFacade stateServiceFacade;
private final StateService stateService;
private final BtcWalletService btcWalletService;
private final BsqBalanceUtil bsqBalanceUtil;
private final Preferences preferences;
@ -112,13 +112,13 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
private BsqTxView(BsqFormatter bsqFormatter,
BsqWalletService bsqWalletService,
Preferences preferences,
StateServiceFacade stateServiceFacade,
StateService stateService,
BtcWalletService btcWalletService,
BsqBalanceUtil bsqBalanceUtil) {
this.bsqFormatter = bsqFormatter;
this.bsqWalletService = bsqWalletService;
this.preferences = preferences;
this.stateServiceFacade = stateServiceFacade;
this.stateService = stateService;
this.btcWalletService = btcWalletService;
this.bsqBalanceUtil = bsqBalanceUtil;
}
@ -177,7 +177,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
tableView.setItems(sortedList);
stateServiceFacade.addBlockListener(this);
stateService.addBlockListener(this);
if (root.getParent() instanceof Pane) {
rootParent = (Pane) root.getParent();
@ -196,7 +196,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
bsqWalletService.getWalletTransactions().removeListener(walletBsqTransactionsListener);
bsqWalletService.removeBsqBalanceListener(this);
btcWalletService.getChainHeightProperty().removeListener(walletChainHeightListener);
stateServiceFacade.removeBlockListener(this);
stateService.removeBlockListener(this);
observableList.forEach(BsqTxListItem::cleanup);
@ -225,7 +225,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
// If chain height from wallet of from the BSQ blockchain parsing changed we update our state.
private void onUpdateAnyChainHeight() {
final int bsqBlockChainHeight = stateServiceFacade.getChainHeight();
final int bsqBlockChainHeight = stateService.getChainHeight();
final int bsqWalletChainHeight = bsqWalletService.getBestChainHeight();
if (bsqWalletChainHeight > 0) {
final boolean synced = bsqWalletChainHeight == bsqBlockChainHeight;
@ -258,13 +258,13 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
final List<Transaction> walletTransactions = new ArrayList<>(bsqWalletService.getWalletTransactions());
List<BsqTxListItem> items = walletTransactions.stream()
.map(transaction -> {
final Optional<Tx> optionalTx = stateServiceFacade.getTx(transaction.getHashAsString());
final Optional<Tx> optionalTx = stateService.getTx(transaction.getHashAsString());
return new BsqTxListItem(transaction,
optionalTx,
bsqWalletService,
btcWalletService,
stateServiceFacade,
stateServiceFacade.hasTxBurntFee(transaction.getHashAsString()),
stateService,
stateService.hasTxBurntFee(transaction.getHashAsString()),
transaction.getUpdateTime(),
bsqFormatter);
})
@ -374,7 +374,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
if (txType == TxType.COMPENSATION_REQUEST &&
optionalTx.isPresent() &&
stateServiceFacade.isIssuanceTx(optionalTx.get().getId())) {
stateService.isIssuanceTx(optionalTx.get().getId())) {
if (field != null)
field.setOnAction(null);
@ -536,11 +536,11 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
case PROPOSAL:
case COMPENSATION_REQUEST:
final String txId = item.getOptionalTx().get().getId();
if (item.getOptionalTx().isPresent() && stateServiceFacade.isIssuanceTx(txId)) {
if (item.getOptionalTx().isPresent() && stateService.isIssuanceTx(txId)) {
awesomeIcon = AwesomeIcon.MONEY;
style = "dao-tx-type-issuance-icon";
final int issuanceBlockHeight = stateServiceFacade.getIssuanceBlockHeight(txId);
long blockTimeInSec = stateServiceFacade.getBlockTime(issuanceBlockHeight);
final int issuanceBlockHeight = stateService.getIssuanceBlockHeight(txId);
long blockTimeInSec = stateService.getBlockTime(issuanceBlockHeight);
final String formattedDate = bsqFormatter.formatDateTime(new Date(blockTimeInSec * 1000));
toolTipText = Res.get("dao.tx.issuance.tooltip", formattedDate);
} else {

View file

@ -21,7 +21,7 @@ import bisq.desktop.util.BSFormatter;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.dao.consensus.state.StateService;
import bisq.core.trade.Tradable;
import org.bitcoinj.core.Transaction;
@ -35,12 +35,12 @@ import javax.annotation.Nullable;
public class TransactionListItemFactory {
private final BtcWalletService btcWalletService;
private final BsqWalletService bsqWalletService;
private final StateServiceFacade stateService;
private final StateService stateService;
private final BSFormatter formatter;
@Inject
TransactionListItemFactory(BtcWalletService btcWalletService, BsqWalletService bsqWalletService,
StateServiceFacade stateService, BSFormatter formatter) {
StateService stateService, BSFormatter formatter) {
this.btcWalletService = btcWalletService;
this.bsqWalletService = bsqWalletService;
this.stateService = stateService;

View file

@ -26,8 +26,8 @@ import bisq.core.btc.listeners.TxConfidenceListener;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.btc.wallet.WalletService;
import bisq.core.dao.consensus.state.StateService;
import bisq.core.dao.consensus.state.blockchain.TxType;
import bisq.core.dao.presentation.state.StateServiceFacade;
import bisq.core.locale.Res;
import bisq.core.offer.Offer;
import bisq.core.offer.OpenOffer;
@ -80,7 +80,7 @@ class TransactionsListItem {
BtcWalletService btcWalletService,
BsqWalletService bsqWalletService,
Optional<Tradable> tradableOptional,
StateServiceFacade stateService,
StateService stateService,
BSFormatter formatter) {
this.formatter = formatter;
txId = transaction.getHashAsString();