mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-28 09:24:15 -04:00
Improve footer info
This commit is contained in:
parent
0908c6d61f
commit
8db55a6616
2 changed files with 148 additions and 130 deletions
|
@ -279,7 +279,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
|
|
||||||
// createBitcoinInfoBox
|
// createBitcoinInfoBox
|
||||||
btcSplashInfo = new Label();
|
btcSplashInfo = new Label();
|
||||||
btcSplashInfo.textProperty().bind(model.btcSplashInfo);
|
btcSplashInfo.textProperty().bind(model.btcInfo);
|
||||||
walletServiceErrorMsgListener = (ov, oldValue, newValue) -> {
|
walletServiceErrorMsgListener = (ov, oldValue, newValue) -> {
|
||||||
btcSplashInfo.setId("splash-error-state-msg");
|
btcSplashInfo.setId("splash-error-state-msg");
|
||||||
};
|
};
|
||||||
|
@ -329,7 +329,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
splashP2PNetworkIndicator.setVisible(false);
|
splashP2PNetworkIndicator.setVisible(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
model.p2PNetworkWarnMsg.addListener(splashP2PNetworkErrorMsgListener);
|
model.p2pNetworkWarnMsg.addListener(splashP2PNetworkErrorMsgListener);
|
||||||
|
|
||||||
|
|
||||||
ImageView splashP2PNetworkIcon = new ImageView();
|
ImageView splashP2PNetworkIcon = new ImageView();
|
||||||
|
@ -367,7 +367,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
model.walletServiceErrorMsg.removeListener(walletServiceErrorMsgListener);
|
model.walletServiceErrorMsg.removeListener(walletServiceErrorMsgListener);
|
||||||
model.btcSplashSyncIconId.removeListener(btcSyncIconIdListener);
|
model.btcSplashSyncIconId.removeListener(btcSyncIconIdListener);
|
||||||
|
|
||||||
model.p2PNetworkWarnMsg.removeListener(splashP2PNetworkErrorMsgListener);
|
model.p2pNetworkWarnMsg.removeListener(splashP2PNetworkErrorMsgListener);
|
||||||
model.p2PNetworkIconId.removeListener(splashP2PNetworkIconIdListener);
|
model.p2PNetworkIconId.removeListener(splashP2PNetworkIconIdListener);
|
||||||
model.splashP2PNetworkProgress.removeListener(splashP2PNetworkProgressListener);
|
model.splashP2PNetworkProgress.removeListener(splashP2PNetworkProgressListener);
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
// BTC
|
// BTC
|
||||||
Label btcInfoLabel = new Label();
|
Label btcInfoLabel = new Label();
|
||||||
btcInfoLabel.setId("footer-pane");
|
btcInfoLabel.setId("footer-pane");
|
||||||
btcInfoLabel.textProperty().bind(model.btcFooterInfo);
|
btcInfoLabel.textProperty().bind(model.btcInfo);
|
||||||
|
|
||||||
ProgressBar blockchainSyncIndicator = new ProgressBar(-1);
|
ProgressBar blockchainSyncIndicator = new ProgressBar(-1);
|
||||||
blockchainSyncIndicator.setPrefWidth(120);
|
blockchainSyncIndicator.setPrefWidth(120);
|
||||||
|
@ -450,8 +450,8 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
setBottomAnchor(p2PNetworkIcon, 7d);
|
setBottomAnchor(p2PNetworkIcon, 7d);
|
||||||
p2PNetworkIcon.setOpacity(0.4);
|
p2PNetworkIcon.setOpacity(0.4);
|
||||||
p2PNetworkIcon.idProperty().bind(model.p2PNetworkIconId);
|
p2PNetworkIcon.idProperty().bind(model.p2PNetworkIconId);
|
||||||
p2PNetworkLabel.idProperty().bind(model.p2PNetworkLabelId);
|
p2PNetworkLabel.idProperty().bind(model.p2pNetworkLabelId);
|
||||||
model.p2PNetworkWarnMsg.addListener((ov, oldValue, newValue) -> {
|
model.p2pNetworkWarnMsg.addListener((ov, oldValue, newValue) -> {
|
||||||
if (newValue != null) {
|
if (newValue != null) {
|
||||||
p2PNetworkWarnMsgPopup = new Popup().warning(newValue);
|
p2PNetworkWarnMsgPopup = new Popup().warning(newValue);
|
||||||
p2PNetworkWarnMsgPopup.show();
|
p2PNetworkWarnMsgPopup.show();
|
||||||
|
|
|
@ -61,7 +61,6 @@ import io.bitsquare.trade.offer.OpenOfferManager;
|
||||||
import io.bitsquare.user.Preferences;
|
import io.bitsquare.user.Preferences;
|
||||||
import io.bitsquare.user.User;
|
import io.bitsquare.user.User;
|
||||||
import javafx.beans.property.*;
|
import javafx.beans.property.*;
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import org.bitcoinj.core.*;
|
import org.bitcoinj.core.*;
|
||||||
import org.bitcoinj.store.BlockStoreException;
|
import org.bitcoinj.store.BlockStoreException;
|
||||||
|
@ -98,8 +97,7 @@ public class MainViewModel implements ViewModel {
|
||||||
private final BSFormatter formatter;
|
private final BSFormatter formatter;
|
||||||
|
|
||||||
// BTC network
|
// BTC network
|
||||||
final StringProperty btcSplashInfo = new SimpleStringProperty("Initializing");
|
final StringProperty btcInfo = new SimpleStringProperty("Initializing");
|
||||||
final StringProperty btcFooterInfo = new SimpleStringProperty("Initializing");
|
|
||||||
final DoubleProperty btcSyncProgress = new SimpleDoubleProperty(-1);
|
final DoubleProperty btcSyncProgress = new SimpleDoubleProperty(-1);
|
||||||
final StringProperty walletServiceErrorMsg = new SimpleStringProperty();
|
final StringProperty walletServiceErrorMsg = new SimpleStringProperty();
|
||||||
final StringProperty btcSplashSyncIconId = new SimpleStringProperty();
|
final StringProperty btcSplashSyncIconId = new SimpleStringProperty();
|
||||||
|
@ -109,11 +107,13 @@ public class MainViewModel implements ViewModel {
|
||||||
final StringProperty availableBalance = new SimpleStringProperty();
|
final StringProperty availableBalance = new SimpleStringProperty();
|
||||||
final StringProperty reservedBalance = new SimpleStringProperty();
|
final StringProperty reservedBalance = new SimpleStringProperty();
|
||||||
final StringProperty lockedBalance = new SimpleStringProperty();
|
final StringProperty lockedBalance = new SimpleStringProperty();
|
||||||
|
private MonadicBinding<String> btcInfoBinding;
|
||||||
|
|
||||||
// P2P network
|
// P2P network
|
||||||
final StringProperty p2PNetworkInfo = new SimpleStringProperty();
|
final StringProperty p2PNetworkInfo = new SimpleStringProperty();
|
||||||
|
private MonadicBinding<String> p2PNetworkInfoBinding;
|
||||||
final DoubleProperty splashP2PNetworkProgress = new SimpleDoubleProperty(-1);
|
final DoubleProperty splashP2PNetworkProgress = new SimpleDoubleProperty(-1);
|
||||||
final StringProperty p2PNetworkWarnMsg = new SimpleStringProperty();
|
final StringProperty p2pNetworkWarnMsg = new SimpleStringProperty();
|
||||||
final StringProperty p2PNetworkIconId = new SimpleStringProperty();
|
final StringProperty p2PNetworkIconId = new SimpleStringProperty();
|
||||||
final BooleanProperty bootstrapComplete = new SimpleBooleanProperty();
|
final BooleanProperty bootstrapComplete = new SimpleBooleanProperty();
|
||||||
|
|
||||||
|
@ -127,15 +127,14 @@ public class MainViewModel implements ViewModel {
|
||||||
final BooleanProperty showOpenDisputesNotification = new SimpleBooleanProperty();
|
final BooleanProperty showOpenDisputesNotification = new SimpleBooleanProperty();
|
||||||
private final BooleanProperty isSplashScreenRemoved = new SimpleBooleanProperty();
|
private final BooleanProperty isSplashScreenRemoved = new SimpleBooleanProperty();
|
||||||
private final String btcNetworkAsString;
|
private final String btcNetworkAsString;
|
||||||
final StringProperty p2PNetworkLabelId = new SimpleStringProperty("footer-pane");
|
final StringProperty p2pNetworkLabelId = new SimpleStringProperty("footer-pane");
|
||||||
|
|
||||||
private MonadicBinding<Boolean> allServicesDone, tradesAndUIReady;
|
private MonadicBinding<Boolean> allServicesDone, tradesAndUIReady;
|
||||||
private final MarketPriceFeed marketPriceFeed;
|
private final MarketPriceFeed marketPriceFeed;
|
||||||
private final User user;
|
private final User user;
|
||||||
private int numBTCPeers = 0;
|
private int numBtcPeers = 0;
|
||||||
private ChangeListener<Number> numConnectedPeersListener, btcNumPeersListener;
|
private Timer checkNumberOfBtcPeersTimer;
|
||||||
private Timer numberOfBtcPeersTimer;
|
private Timer checkNumberOfP2pNetworkPeersTimer;
|
||||||
private Timer numberOfP2PNetworkPeersTimer;
|
|
||||||
private Timer startupTimeout;
|
private Timer startupTimeout;
|
||||||
private final Map<String, Subscription> disputeIsClosedSubscriptionsMap = new HashMap<>();
|
private final Map<String, Subscription> disputeIsClosedSubscriptionsMap = new HashMap<>();
|
||||||
private Subscription downloadPercentageSubscription;
|
private Subscription downloadPercentageSubscription;
|
||||||
|
@ -222,14 +221,6 @@ public class MainViewModel implements ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutDown() {
|
public void shutDown() {
|
||||||
if (numConnectedPeersListener != null)
|
|
||||||
p2PService.getNumConnectedPeers().removeListener(numConnectedPeersListener);
|
|
||||||
|
|
||||||
if (btcNumPeersListener != null)
|
|
||||||
walletService.numPeersProperty().removeListener(btcNumPeersListener);
|
|
||||||
|
|
||||||
if (downloadPercentageSubscription != null)
|
|
||||||
downloadPercentageSubscription.unsubscribe();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,8 +229,33 @@ public class MainViewModel implements ViewModel {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private BooleanProperty initP2PNetwork() {
|
private BooleanProperty initP2PNetwork() {
|
||||||
final BooleanProperty p2pNetworkInitialized = new SimpleBooleanProperty();
|
StringProperty bootstrapState = new SimpleStringProperty();
|
||||||
p2PNetworkInfo.set("Connecting to Tor network...");
|
StringProperty bootstrapWarning = new SimpleStringProperty();
|
||||||
|
BooleanProperty hiddenServicePublished = new SimpleBooleanProperty();
|
||||||
|
BooleanProperty initialP2PNetworkDataReceived = new SimpleBooleanProperty();
|
||||||
|
|
||||||
|
p2PNetworkInfoBinding = EasyBind.combine(bootstrapState, bootstrapWarning, p2PService.getNumConnectedPeers(), hiddenServicePublished, initialP2PNetworkDataReceived,
|
||||||
|
(state, warning, numPeers, hiddenService, dataReceived) -> {
|
||||||
|
String result = "";
|
||||||
|
int peers = (int) numPeers;
|
||||||
|
if (warning != null && peers == 0) {
|
||||||
|
result = warning;
|
||||||
|
} else {
|
||||||
|
if (dataReceived && hiddenService)
|
||||||
|
result = "Nr. of P2P network peers: " + numPeers;
|
||||||
|
else if (peers == 0)
|
||||||
|
result = state;
|
||||||
|
else
|
||||||
|
result = state + " / Nr. of P2P network peers: " + numPeers;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
p2PNetworkInfoBinding.subscribe((observable, oldValue, newValue) -> {
|
||||||
|
p2PNetworkInfo.set(newValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
bootstrapState.set("Connecting to Tor network...");
|
||||||
|
|
||||||
p2PService.getNetworkNode().addConnectionListener(new ConnectionListener() {
|
p2PService.getNetworkNode().addConnectionListener(new ConnectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onConnection(Connection connection) {
|
public void onConnection(Connection connection) {
|
||||||
|
@ -258,8 +274,7 @@ public class MainViewModel implements ViewModel {
|
||||||
"the network.\n\n" +
|
"the network.\n\n" +
|
||||||
"Please check if you run the latest software version.\n" +
|
"Please check if you run the latest software version.\n" +
|
||||||
"You can download the latest version of Bitsquare at:\n" +
|
"You can download the latest version of Bitsquare at:\n" +
|
||||||
"https://github.com/bitsquare/bitsquare/releases/\n\n" +
|
"https://github.com/bitsquare/bitsquare/releases")
|
||||||
"")
|
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,63 +283,66 @@ public class MainViewModel implements ViewModel {
|
||||||
public void onError(Throwable throwable) {
|
public void onError(Throwable throwable) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final BooleanProperty p2pNetworkInitialized = new SimpleBooleanProperty();
|
||||||
p2PService.start(new P2PServiceListener() {
|
p2PService.start(new P2PServiceListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTorNodeReady() {
|
public void onTorNodeReady() {
|
||||||
p2PNetworkInfo.set("Tor node created");
|
bootstrapState.set("Tor node created");
|
||||||
p2PNetworkIconId.set("image-connection-tor");
|
p2PNetworkIconId.set("image-connection-tor");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHiddenServicePublished() {
|
public void onHiddenServicePublished() {
|
||||||
p2PNetworkInfo.set("Hidden Service published");
|
hiddenServicePublished.set(true);
|
||||||
|
bootstrapState.set("Hidden Service published");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestingDataCompleted() {
|
public void onRequestingDataCompleted() {
|
||||||
if (p2PService.getNumConnectedPeers().get() == 0) {
|
initialP2PNetworkDataReceived.set(true);
|
||||||
p2PNetworkInfo.set("Initial data received");
|
bootstrapState.set("Initial data received");
|
||||||
} else {
|
|
||||||
updateP2pNetworkInfoWithPeersChanged(p2PService.getNumConnectedPeers().get());
|
|
||||||
}
|
|
||||||
p2pNetworkInitialized.set(true);
|
p2pNetworkInitialized.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNoSeedNodeAvailable() {
|
public void onNoSeedNodeAvailable() {
|
||||||
if (p2PService.getNumConnectedPeers().get() == 0) {
|
if (p2PService.getNumConnectedPeers().get() == 0)
|
||||||
p2PNetworkInfo.set("No seed nodes available");
|
bootstrapWarning.set("No seed nodes available");
|
||||||
}
|
else
|
||||||
|
bootstrapWarning.set(null);
|
||||||
|
|
||||||
p2pNetworkInitialized.set(true);
|
p2pNetworkInitialized.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNoPeersAvailable() {
|
public void onNoPeersAvailable() {
|
||||||
if (p2PService.getNumConnectedPeers().get() == 0) {
|
if (p2PService.getNumConnectedPeers().get() == 0) {
|
||||||
p2PNetworkWarnMsg.set("There are no seed nodes or persisted peers available for requesting data.\n" +
|
p2pNetworkWarnMsg.set("There are no seed nodes or persisted peers available for requesting data.\n" +
|
||||||
"Please check your internet connection or try to restart the application.");
|
"Please check your internet connection or try to restart the application.");
|
||||||
p2PNetworkInfo.set("No seed nodes and peers available");
|
bootstrapWarning.set("No seed nodes and peers available");
|
||||||
p2PNetworkLabelId.set("splash-error-state-msg");
|
p2pNetworkLabelId.set("splash-error-state-msg");
|
||||||
|
} else {
|
||||||
|
bootstrapWarning.set(null);
|
||||||
|
p2pNetworkLabelId.set("footer-pane");
|
||||||
}
|
}
|
||||||
p2pNetworkInitialized.set(true);
|
p2pNetworkInitialized.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBootstrapComplete() {
|
public void onBootstrapComplete() {
|
||||||
updateP2pNetworkInfoWithPeersChanged(p2PService.getNumConnectedPeers().get());
|
|
||||||
splashP2PNetworkProgress.set(1);
|
splashP2PNetworkProgress.set(1);
|
||||||
bootstrapComplete.set(true);
|
bootstrapComplete.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetupFailed(Throwable throwable) {
|
public void onSetupFailed(Throwable throwable) {
|
||||||
p2PNetworkWarnMsg.set("Connecting to the P2P network failed (reported error: "
|
p2pNetworkWarnMsg.set("Connecting to the P2P network failed (reported error: "
|
||||||
+ throwable.getMessage() + ").\n" +
|
+ throwable.getMessage() + ").\n" +
|
||||||
"Please check your internet connection or try to restart the application.");
|
"Please check your internet connection or try to restart the application.");
|
||||||
splashP2PNetworkProgress.set(0);
|
splashP2PNetworkProgress.set(0);
|
||||||
if (p2PService.getNumConnectedPeers().get() == 0)
|
bootstrapWarning.set("Bootstrapping to P2P network failed");
|
||||||
p2PNetworkLabelId.set("splash-error-state-msg");
|
p2pNetworkLabelId.set("splash-error-state-msg");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -332,38 +350,53 @@ public class MainViewModel implements ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private BooleanProperty initBitcoinWallet() {
|
private BooleanProperty initBitcoinWallet() {
|
||||||
downloadPercentageSubscription = EasyBind.subscribe(walletService.downloadPercentageProperty(),
|
ObjectProperty<Throwable> walletServiceException = new SimpleObjectProperty<>();
|
||||||
percentage -> setBitcoinNetworkSyncProgress((double) percentage));
|
btcInfoBinding = EasyBind.combine(walletService.downloadPercentageProperty(), walletService.numPeersProperty(), walletServiceException,
|
||||||
|
(downloadPercentage, numPeers, exception) -> {
|
||||||
|
String result = "";
|
||||||
|
if (exception == null) {
|
||||||
|
double percentage = (double) downloadPercentage;
|
||||||
|
int peers = (int) numPeers;
|
||||||
|
String numPeersString = "Nr. of Bitcoin network peers: " + peers;
|
||||||
|
|
||||||
btcNumPeersListener = (observable, oldValue, newValue) -> {
|
btcSyncProgress.set(percentage);
|
||||||
if ((int) oldValue > 0 && (int) newValue == 0) {
|
if (percentage == 1) {
|
||||||
// give a bit of tolerance
|
result = numPeersString + " / synchronized with " + btcNetworkAsString;
|
||||||
if (numberOfBtcPeersTimer != null)
|
btcSplashSyncIconId.set("image-connection-synced");
|
||||||
numberOfBtcPeersTimer.stop();
|
} else if (percentage > 0.0) {
|
||||||
numberOfBtcPeersTimer = UserThread.runAfter(() -> {
|
result = numPeersString + " / synchronizing with " + btcNetworkAsString + ": " + formatter.formatToPercent(percentage);
|
||||||
if (walletService.numPeersProperty().get() == 0) {
|
|
||||||
walletServiceErrorMsg.set("You lost the connection to all bitcoin network peers.\n" +
|
|
||||||
"Maybe you lost your internet connection or your computer was in standby mode.");
|
|
||||||
} else {
|
} else {
|
||||||
walletServiceErrorMsg.set(null);
|
result = numPeersString + " / connecting to " + btcNetworkAsString;
|
||||||
}
|
}
|
||||||
}, 5);
|
} else {
|
||||||
} else if ((int) oldValue == 0 && (int) newValue > 0) {
|
result = "Nr. of Bitcoin network peers: " + numBtcPeers + " / connecting to " + btcNetworkAsString + " failed";
|
||||||
walletServiceErrorMsg.set(null);
|
if (exception instanceof TimeoutException) {
|
||||||
|
walletServiceErrorMsg.set("Connecting to the bitcoin network failed because of a timeout.");
|
||||||
|
} else if (exception.getCause() instanceof BlockStoreException) {
|
||||||
|
new Popup().warning("Bitsquare is already running. You cannot run 2 instances of Bitsquare.")
|
||||||
|
.closeButtonText("Shut down")
|
||||||
|
.onClose(BitsquareApp.shutDownHandler::run)
|
||||||
|
.show();
|
||||||
|
} else if (exception.getMessage() != null) {
|
||||||
|
walletServiceErrorMsg.set("Connection to the bitcoin network failed because of an error:" + exception.getMessage());
|
||||||
|
} else {
|
||||||
|
walletServiceErrorMsg.set("Connection to the bitcoin network failed because of an error:" + exception.toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
numBTCPeers = (int) newValue;
|
});
|
||||||
};
|
btcInfoBinding.subscribe((observable, oldValue, newValue) -> {
|
||||||
|
btcInfo.set(newValue);
|
||||||
walletService.numPeersProperty().addListener(btcNumPeersListener);
|
});
|
||||||
|
|
||||||
final BooleanProperty walletInitialized = new SimpleBooleanProperty();
|
final BooleanProperty walletInitialized = new SimpleBooleanProperty();
|
||||||
walletService.initialize(null,
|
walletService.initialize(null,
|
||||||
() -> {
|
() -> {
|
||||||
log.trace("wallet initialized");
|
numBtcPeers = walletService.numPeersProperty().get();
|
||||||
walletInitialized.set(true);
|
walletInitialized.set(true);
|
||||||
},
|
},
|
||||||
errorMessage -> setWalletServiceException(errorMessage));
|
walletServiceException::set);
|
||||||
return walletInitialized;
|
return walletInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +449,8 @@ public class MainViewModel implements ViewModel {
|
||||||
alertManager.alertMessageProperty().addListener((observable, oldValue, newValue) -> displayAlertIfPresent(newValue));
|
alertManager.alertMessageProperty().addListener((observable, oldValue, newValue) -> displayAlertIfPresent(newValue));
|
||||||
displayAlertIfPresent(alertManager.alertMessageProperty().get());
|
displayAlertIfPresent(alertManager.alertMessageProperty().get());
|
||||||
|
|
||||||
setupP2PPeersInfo();
|
setupBtcNumPeersWatcher();
|
||||||
|
setupP2PNumPeersWatcher();
|
||||||
updateBalance();
|
updateBalance();
|
||||||
setupDevDummyPaymentAccount();
|
setupDevDummyPaymentAccount();
|
||||||
setupMarketPriceFeed();
|
setupMarketPriceFeed();
|
||||||
|
@ -525,32 +559,58 @@ public class MainViewModel implements ViewModel {
|
||||||
// Private
|
// Private
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private void setupP2PPeersInfo() {
|
private void setupP2PNumPeersWatcher() {
|
||||||
numConnectedPeersListener = (observable, oldValue, newValue) -> {
|
p2PService.getNumConnectedPeers().addListener((observable, oldValue, newValue) -> {
|
||||||
if ((int) oldValue > 0 && (int) newValue == 0) {
|
int numPeers = (int) newValue;
|
||||||
|
if ((int) oldValue > 0 && numPeers == 0) {
|
||||||
// give a bit of tolerance
|
// give a bit of tolerance
|
||||||
if (numberOfP2PNetworkPeersTimer != null)
|
if (checkNumberOfP2pNetworkPeersTimer != null)
|
||||||
numberOfP2PNetworkPeersTimer.stop();
|
checkNumberOfP2pNetworkPeersTimer.stop();
|
||||||
numberOfP2PNetworkPeersTimer = UserThread.runAfter(() -> {
|
|
||||||
|
checkNumberOfP2pNetworkPeersTimer = UserThread.runAfter(() -> {
|
||||||
|
// check again numPeers
|
||||||
if (p2PService.getNumConnectedPeers().get() == 0) {
|
if (p2PService.getNumConnectedPeers().get() == 0) {
|
||||||
p2PNetworkWarnMsg.set("You lost the connection to all P2P network peers.\n" +
|
p2pNetworkWarnMsg.set("You lost the connection to all P2P network peers.\n" +
|
||||||
"Maybe you lost your internet connection or your computer was in standby mode.");
|
"Maybe you lost your internet connection or your computer was in standby mode.");
|
||||||
p2PNetworkLabelId.set("splash-error-state-msg");
|
p2pNetworkLabelId.set("splash-error-state-msg");
|
||||||
} else {
|
} else {
|
||||||
p2PNetworkWarnMsg.set(null);
|
p2pNetworkWarnMsg.set(null);
|
||||||
p2PNetworkLabelId.set("footer-pane");
|
p2pNetworkLabelId.set("footer-pane");
|
||||||
}
|
}
|
||||||
}, 5);
|
}, 5);
|
||||||
} else if ((int) oldValue == 0 && (int) newValue > 0) {
|
} else if ((int) oldValue == 0 && numPeers > 0) {
|
||||||
p2PNetworkWarnMsg.set(null);
|
if (checkNumberOfP2pNetworkPeersTimer != null)
|
||||||
p2PNetworkLabelId.set("footer-pane");
|
checkNumberOfP2pNetworkPeersTimer.stop();
|
||||||
|
|
||||||
|
p2pNetworkWarnMsg.set(null);
|
||||||
|
p2pNetworkLabelId.set("footer-pane");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateP2pNetworkInfoWithPeersChanged((int) newValue);
|
private void setupBtcNumPeersWatcher() {
|
||||||
};
|
walletService.numPeersProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
p2PService.getNumConnectedPeers().addListener(numConnectedPeersListener);
|
int numPeers = (int) newValue;
|
||||||
}
|
if ((int) oldValue > 0 && numPeers == 0) {
|
||||||
|
if (checkNumberOfBtcPeersTimer != null)
|
||||||
|
checkNumberOfBtcPeersTimer.stop();
|
||||||
|
|
||||||
|
checkNumberOfBtcPeersTimer = UserThread.runAfter(() -> {
|
||||||
|
// check again numPeers
|
||||||
|
if (walletService.numPeersProperty().get() == 0) {
|
||||||
|
walletServiceErrorMsg.set("You lost the connection to all bitcoin network peers.\n" +
|
||||||
|
"Maybe you lost your internet connection or your computer was in standby mode.");
|
||||||
|
} else {
|
||||||
|
walletServiceErrorMsg.set(null);
|
||||||
|
}
|
||||||
|
}, 5);
|
||||||
|
} else if ((int) oldValue == 0 && numPeers > 0) {
|
||||||
|
if (checkNumberOfBtcPeersTimer != null)
|
||||||
|
checkNumberOfBtcPeersTimer.stop();
|
||||||
|
walletServiceErrorMsg.set(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void setupMarketPriceFeed() {
|
private void setupMarketPriceFeed() {
|
||||||
if (marketPriceFeed.getCurrencyCode() == null)
|
if (marketPriceFeed.getCurrencyCode() == null)
|
||||||
|
@ -567,10 +627,6 @@ public class MainViewModel implements ViewModel {
|
||||||
typeProperty.bind(marketPriceFeed.typeProperty());
|
typeProperty.bind(marketPriceFeed.typeProperty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateP2pNetworkInfoWithPeersChanged(int numPeers) {
|
|
||||||
p2PNetworkInfo.set("Nr. of P2P network peers: " + numPeers);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayAlertIfPresent(Alert alert) {
|
private void displayAlertIfPresent(Alert alert) {
|
||||||
boolean alreadyDisplayed = alert != null && alert.equals(user.getDisplayedAlert());
|
boolean alreadyDisplayed = alert != null && alert.equals(user.getDisplayedAlert());
|
||||||
user.setDisplayedAlert(alert);
|
user.setDisplayedAlert(alert);
|
||||||
|
@ -632,7 +688,7 @@ public class MainViewModel implements ViewModel {
|
||||||
.filter(e -> !reservedTrades.contains(e.getOfferId()))
|
.filter(e -> !reservedTrades.contains(e.getOfferId()))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
Optional<Coin> totalAvailableOptional = result.stream().map(e -> walletService.getBalanceForAddress(e.getAddress())).reduce((a, b) -> a.add(b));
|
Optional<Coin> totalAvailableOptional = result.stream().map(e -> walletService.getBalanceForAddress(e.getAddress())).reduce(Coin::add);
|
||||||
if (totalAvailableOptional.isPresent())
|
if (totalAvailableOptional.isPresent())
|
||||||
availableBalance.set(formatter.formatCoinWithCode(totalAvailableOptional.get()));
|
availableBalance.set(formatter.formatCoinWithCode(totalAvailableOptional.get()));
|
||||||
else
|
else
|
||||||
|
@ -663,7 +719,7 @@ public class MainViewModel implements ViewModel {
|
||||||
if (openDisputes > 0)
|
if (openDisputes > 0)
|
||||||
numOpenDisputesAsString.set(String.valueOf(openDisputes));
|
numOpenDisputesAsString.set(String.valueOf(openDisputes));
|
||||||
if (openDisputes > 9)
|
if (openDisputes > 9)
|
||||||
numOpenDisputesAsString.set("?");
|
numOpenDisputesAsString.set("*");
|
||||||
|
|
||||||
showOpenDisputesNotification.set(openDisputes > 0);
|
showOpenDisputesNotification.set(openDisputes > 0);
|
||||||
});
|
});
|
||||||
|
@ -677,49 +733,11 @@ public class MainViewModel implements ViewModel {
|
||||||
if (numPendingTrades > 0)
|
if (numPendingTrades > 0)
|
||||||
numPendingTradesAsString.set(String.valueOf(numPendingTrades));
|
numPendingTradesAsString.set(String.valueOf(numPendingTrades));
|
||||||
if (numPendingTrades > 9)
|
if (numPendingTrades > 9)
|
||||||
numPendingTradesAsString.set("?");
|
numPendingTradesAsString.set("*");
|
||||||
|
|
||||||
showPendingTradesNotification.set(numPendingTrades > 0);
|
showPendingTradesNotification.set(numPendingTrades > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBitcoinNetworkSyncProgress(double value) {
|
|
||||||
btcSyncProgress.set(value);
|
|
||||||
String numPeers = "Nr. of Bitcoin network peers: " + numBTCPeers;
|
|
||||||
if (value == 1) {
|
|
||||||
btcSplashInfo.set(numPeers + " / synchronized with " + btcNetworkAsString);
|
|
||||||
btcFooterInfo.set(btcSplashInfo.get());
|
|
||||||
btcSplashSyncIconId.set("image-connection-synced");
|
|
||||||
if (downloadPercentageSubscription != null)
|
|
||||||
downloadPercentageSubscription.unsubscribe();
|
|
||||||
} else if (value > 0.0) {
|
|
||||||
String percentage = formatter.formatToPercent(value);
|
|
||||||
btcSplashInfo.set(numPeers + " / synchronizing with " + btcNetworkAsString + ": " + percentage);
|
|
||||||
btcFooterInfo.set(numPeers + " / synchronizing " + btcNetworkAsString + ": " + percentage);
|
|
||||||
} else if (value == -1) {
|
|
||||||
btcSplashInfo.set(numPeers + " / connecting to " + btcNetworkAsString);
|
|
||||||
btcFooterInfo.set(btcSplashInfo.get());
|
|
||||||
} else {
|
|
||||||
log.error("Not allowed value at setBitcoinNetworkSyncProgress: " + value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setWalletServiceException(Throwable error) {
|
|
||||||
btcSplashInfo.set("Nr. of Bitcoin network peers: " + numBTCPeers + " / connecting to " + btcNetworkAsString + " failed");
|
|
||||||
btcFooterInfo.set(btcSplashInfo.get());
|
|
||||||
if (error instanceof TimeoutException) {
|
|
||||||
walletServiceErrorMsg.set("Connecting to the bitcoin network failed because of a timeout.");
|
|
||||||
} else if (error.getCause() instanceof BlockStoreException) {
|
|
||||||
new Popup().warning("Bitsquare is already running. You cannot run 2 instances of Bitsquare.")
|
|
||||||
.closeButtonText("Shut down")
|
|
||||||
.onClose(BitsquareApp.shutDownHandler::run)
|
|
||||||
.show();
|
|
||||||
} else if (error.getMessage() != null) {
|
|
||||||
walletServiceErrorMsg.set("Connection to the bitcoin network failed because of an error:" + error.getMessage());
|
|
||||||
} else {
|
|
||||||
walletServiceErrorMsg.set("Connection to the bitcoin network failed because of an error:" + error.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupDevDummyPaymentAccount() {
|
private void setupDevDummyPaymentAccount() {
|
||||||
if (BitsquareApp.DEV_MODE && user.getPaymentAccounts().isEmpty()) {
|
if (BitsquareApp.DEV_MODE && user.getPaymentAccounts().isEmpty()) {
|
||||||
OKPayAccount okPayAccount = new OKPayAccount();
|
OKPayAccount okPayAccount = new OKPayAccount();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue