Use dev seed nodes, move code to data model

This commit is contained in:
Manfred Karrer 2016-03-16 13:09:52 +01:00
parent dcd1f8636a
commit bb625ad036
3 changed files with 27 additions and 25 deletions

View File

@ -19,28 +19,35 @@ package io.bitsquare.gui.main.account.content.altcoinaccounts;
import com.google.inject.Inject;
import io.bitsquare.gui.common.model.ActivatableDataModel;
import io.bitsquare.locale.CryptoCurrency;
import io.bitsquare.locale.FiatCurrency;
import io.bitsquare.locale.TradeCurrency;
import io.bitsquare.payment.PaymentAccount;
import io.bitsquare.payment.PaymentMethod;
import io.bitsquare.trade.TradeManager;
import io.bitsquare.trade.offer.OpenOfferManager;
import io.bitsquare.user.Preferences;
import io.bitsquare.user.User;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.SetChangeListener;
import java.util.List;
import java.util.stream.Collectors;
class AltCoinAccountsDataModel extends ActivatableDataModel {
private final User user;
private Preferences preferences;
private final OpenOfferManager openOfferManager;
private final TradeManager tradeManager;
final ObservableList<PaymentAccount> paymentAccounts = FXCollections.observableArrayList();
private final SetChangeListener<PaymentAccount> setChangeListener;
@Inject
public AltCoinAccountsDataModel(User user, OpenOfferManager openOfferManager, TradeManager tradeManager) {
public AltCoinAccountsDataModel(User user, Preferences preferences, OpenOfferManager openOfferManager, TradeManager tradeManager) {
this.user = user;
this.preferences = preferences;
this.openOfferManager = openOfferManager;
this.tradeManager = tradeManager;
setChangeListener = change -> fillAndSortPaymentAccounts();
@ -71,6 +78,21 @@ class AltCoinAccountsDataModel extends ActivatableDataModel {
public void onSaveNewAccount(PaymentAccount paymentAccount) {
user.addPaymentAccount(paymentAccount);
TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
List<TradeCurrency> tradeCurrencies = paymentAccount.getTradeCurrencies();
if (singleTradeCurrency != null) {
if (singleTradeCurrency instanceof FiatCurrency)
preferences.addFiatCurrency((FiatCurrency) singleTradeCurrency);
else
preferences.addCryptoCurrency((CryptoCurrency) singleTradeCurrency);
} else if (tradeCurrencies != null && !tradeCurrencies.isEmpty()) {
tradeCurrencies.stream().forEach(tradeCurrency -> {
if (tradeCurrency instanceof FiatCurrency)
preferences.addFiatCurrency((FiatCurrency) tradeCurrency);
else
preferences.addCryptoCurrency((CryptoCurrency) tradeCurrency);
});
}
}

View File

@ -20,15 +20,10 @@ package io.bitsquare.gui.main.account.content.altcoinaccounts;
import com.google.inject.Inject;
import io.bitsquare.gui.common.model.ActivatableWithDataModel;
import io.bitsquare.gui.common.model.ViewModel;
import io.bitsquare.locale.CryptoCurrency;
import io.bitsquare.locale.FiatCurrency;
import io.bitsquare.locale.TradeCurrency;
import io.bitsquare.payment.PaymentAccount;
import io.bitsquare.user.Preferences;
import javafx.collections.ObservableList;
import java.util.List;
class AltCoinAccountsViewModel extends ActivatableWithDataModel<AltCoinAccountsDataModel> implements ViewModel {
@ -55,21 +50,6 @@ class AltCoinAccountsViewModel extends ActivatableWithDataModel<AltCoinAccountsD
public void onSaveNewAccount(PaymentAccount paymentAccount) {
dataModel.onSaveNewAccount(paymentAccount);
TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
List<TradeCurrency> tradeCurrencies = paymentAccount.getTradeCurrencies();
if (singleTradeCurrency != null) {
if (singleTradeCurrency instanceof FiatCurrency)
preferences.addFiatCurrency((FiatCurrency) singleTradeCurrency);
else
preferences.addCryptoCurrency((CryptoCurrency) singleTradeCurrency);
} else if (tradeCurrencies != null && !tradeCurrencies.isEmpty()) {
tradeCurrencies.stream().forEach(tradeCurrency -> {
if (tradeCurrency instanceof FiatCurrency)
preferences.addFiatCurrency((FiatCurrency) tradeCurrency);
else
preferences.addCryptoCurrency((CryptoCurrency) tradeCurrency);
});
}
}
public boolean onDeleteAccount(PaymentAccount paymentAccount) {

View File

@ -32,15 +32,15 @@ public class SeedNodesRepository {
new NodeAddress("izs5oz7i5ta7c2ir.onion:8000"),*/
// v0.3.5
new NodeAddress("hulvbm5xjn7b7ku4.onion:8000"),
/* new NodeAddress("hulvbm5xjn7b7ku4.onion:8000"),
new NodeAddress("3efgjjbdvhbvck3x.onion:8000"),
new NodeAddress("3unfcshgwipxhxfm.onion:8000"),
new NodeAddress("3unfcshgwipxhxfm.onion:8000"),*/
// v0.3.6
/* new NodeAddress("ybmi4iaesugslxrw.onion:8000"),
new NodeAddress("ybmi4iaesugslxrw.onion:8000"),
new NodeAddress("ufwnvo775jfnjeux.onion:8000"),
new NodeAddress("b66vnevaljo6xt5a.onion:8000"),*/
new NodeAddress("b66vnevaljo6xt5a.onion:8000"),
// testnet
new NodeAddress("znmy44wcstn2rkva.onion:8001"),