Skip to content

Commit

Permalink
Merge pull request #9 from sqrrm/dao
Browse files Browse the repository at this point in the history
Dao
  • Loading branch information
ManfredKarrer authored Jul 16, 2018
2 parents 9f01e9e + d0cfd61 commit 198afcd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.dao.DaoFacade;
import bisq.core.dao.state.StateService;
import bisq.core.dao.state.blockchain.TxOutput;
import bisq.core.dao.state.blockchain.TxType;
import bisq.core.locale.Res;
Expand All @@ -51,9 +50,6 @@ class LockupTxListItem {
private final BtcWalletService btcWalletService;
private final DaoFacade daoFacade;

//TODO SQ stateService should not be used outside in desktop
private final StateService stateService;

private final BsqFormatter bsqFormatter;
private final Date date;
private final String txId;
Expand All @@ -71,14 +67,12 @@ class LockupTxListItem {
BsqWalletService bsqWalletService,
BtcWalletService btcWalletService,
DaoFacade daoFacade,
StateService stateService,
Date date,
BsqFormatter bsqFormatter) {
this.transaction = transaction;
this.bsqWalletService = bsqWalletService;
this.btcWalletService = btcWalletService;
this.daoFacade = daoFacade;
this.stateService = stateService;
this.date = date;
this.bsqFormatter = bsqFormatter;

Expand All @@ -89,8 +83,7 @@ class LockupTxListItem {
checkNotNull(transaction, "transaction must not be null as we only have list items from transactions " +
"which are available in the wallet");

//TODO SQ use daoFacade
stateService.getLockupTxOutput(transaction.getHashAsString())
daoFacade.getLockupTxOutput(transaction.getHashAsString())
.ifPresent(out -> amount = Coin.valueOf(out.getValue()));

Optional<Integer> opLockTime = daoFacade.getLockTime(transaction.getHashAsString());
Expand Down Expand Up @@ -138,7 +131,7 @@ public void cleanup() {

public boolean isSpent() {
Optional<TxOutput> optionalTxOutput = daoFacade.getLockupTxOutput(txId);
return optionalTxOutput.map(txOutput -> !stateService.isUnspent(txOutput.getKey()))
return optionalTxOutput.map(txOutput -> !daoFacade.isUnspent(txOutput.getKey()))
.orElse(true);

}
Expand Down
29 changes: 3 additions & 26 deletions src/main/java/bisq/desktop/main/dao/bonding/unlock/UnlockView.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
import bisq.desktop.common.view.FxmlView;
import bisq.desktop.components.AutoTooltipTableColumn;
import bisq.desktop.components.HyperlinkWithIcon;
import bisq.desktop.main.MainView;
import bisq.desktop.main.dao.wallet.BsqBalanceUtil;
import bisq.desktop.main.funds.FundsView;
import bisq.desktop.main.funds.deposit.DepositView;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.validation.BsqValidator;
Expand All @@ -36,7 +33,6 @@
import bisq.core.btc.wallet.WalletsSetup;
import bisq.core.dao.DaoFacade;
import bisq.core.dao.state.BlockListener;
import bisq.core.dao.state.StateService;
import bisq.core.dao.state.blockchain.Block;
import bisq.core.dao.state.blockchain.TxOutput;
import bisq.core.dao.state.blockchain.TxType;
Expand All @@ -47,7 +43,6 @@
import bisq.network.p2p.P2PService;

import org.bitcoinj.core.Coin;
import org.bitcoinj.core.InsufficientMoneyException;
import org.bitcoinj.core.Transaction;

import javax.inject.Inject;
Expand Down Expand Up @@ -92,9 +87,6 @@ public class UnlockView extends ActivatableView<GridPane, Void> implements BsqBa
private final DaoFacade daoFacade;
private final Preferences preferences;

//TODO SQ stateService should not be used outside in desktop
private final StateService stateService;

private final WalletsSetup walletsSetup;
private final P2PService p2PService;
private final Navigation navigation;
Expand Down Expand Up @@ -122,7 +114,6 @@ private UnlockView(BsqWalletService bsqWalletService,
BsqValidator bsqValidator,
DaoFacade daoFacade,
Preferences preferences,
StateService stateService,
WalletsSetup walletsSetup,
P2PService p2PService,
Navigation navigation) {
Expand All @@ -133,7 +124,6 @@ private UnlockView(BsqWalletService bsqWalletService,
this.bsqValidator = bsqValidator;
this.daoFacade = daoFacade;
this.preferences = preferences;
this.stateService = stateService;
this.walletsSetup = walletsSetup;
this.p2PService = p2PService;
this.navigation = navigation;
Expand Down Expand Up @@ -340,21 +330,9 @@ private void onButtonClick() {
.closeButtonText(Res.get("shared.cancel"))
.show();
} catch (Throwable t) {
//TODO SQ conde analysis of intellij says that the following is always false, but don't understand why...
// but mostly they are right ;-)
if (t instanceof InsufficientMoneyException) {
final Coin missingCoin = ((InsufficientMoneyException) t).missing;
final String missing = missingCoin != null ? missingCoin.toFriendlyString() : "null";
//noinspection unchecked
new Popup<>().warning(Res.get("popup.warning.insufficientBtcFundsForBsqTx", missing))
.actionButtonTextWithGoTo("navigation.funds.depositFunds")
.onAction(() -> navigation.navigateTo(MainView.class, FundsView.class, DepositView.class))
.show();
} else {
log.error(t.toString());
t.printStackTrace();
new Popup<>().warning(t.getMessage()).show();
}
log.error(t.toString());
t.printStackTrace();
new Popup<>().warning(t.getMessage()).show();
}
} else {
GUIUtil.showNotReadyForTxBroadcastPopups(p2PService, walletsSetup);
Expand Down Expand Up @@ -415,7 +393,6 @@ private void updateList() {
bsqWalletService,
btcWalletService,
daoFacade,
stateService,
transaction.getUpdateTime(),
bsqFormatter);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

// We use here ChainHeightListener because we are interested in period changes not in the result of a completed
// block. The event from the ChainHeightListener is sent before parsing starts.
// The event from the StateService.Listener would notify after parsing a new block.
// The event from the ChainHeightListener would notify after parsing a new block.
@FxmlView
public class ProposalDashboardView extends ActivatableView<GridPane, Void> implements ChainHeightListener {
private final DaoFacade daoFacade;
Expand Down

0 comments on commit 198afcd

Please sign in to comment.