mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-26 00:15:18 -04:00
Improve info messages at startup
This commit is contained in:
parent
be108a3035
commit
4bd3a8cb3f
3 changed files with 93 additions and 124 deletions
|
@ -77,14 +77,14 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
private static Transitions transitions;
|
private static Transitions transitions;
|
||||||
private final String title;
|
private final String title;
|
||||||
private ChangeListener<String> walletServiceErrorMsgListener;
|
private ChangeListener<String> walletServiceErrorMsgListener;
|
||||||
private ChangeListener<String> blockchainSyncIconIdListener;
|
private ChangeListener<String> btcSyncIconIdListener;
|
||||||
private ChangeListener<String> splashP2PNetworkErrorMsgListener;
|
private ChangeListener<String> splashP2PNetworkErrorMsgListener;
|
||||||
private ChangeListener<String> splashP2PNetworkIconIdListener;
|
private ChangeListener<String> splashP2PNetworkIconIdListener;
|
||||||
private ChangeListener<Number> splashP2PNetworkProgressListener;
|
private ChangeListener<Number> splashP2PNetworkProgressListener;
|
||||||
private ProgressIndicator splashP2PNetworkIndicator;
|
private ProgressIndicator splashP2PNetworkIndicator;
|
||||||
private Label splashP2PNetworkLabel;
|
private Label splashP2PNetworkLabel;
|
||||||
private ProgressBar blockchainSyncIndicator;
|
private ProgressBar btcSyncIndicator;
|
||||||
private Label blockchainSyncLabel;
|
private Label btcSplashInfo;
|
||||||
private List<String> persistedFilesCorrupted;
|
private List<String> persistedFilesCorrupted;
|
||||||
private static BorderPane baseApplicationContainer;
|
private static BorderPane baseApplicationContainer;
|
||||||
|
|
||||||
|
@ -225,42 +225,38 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
|
|
||||||
|
|
||||||
// createBitcoinInfoBox
|
// createBitcoinInfoBox
|
||||||
blockchainSyncLabel = new Label();
|
btcSplashInfo = new Label();
|
||||||
blockchainSyncLabel.textProperty().bind(model.blockchainSyncInfo);
|
btcSplashInfo.textProperty().bind(model.btcSplashInfo);
|
||||||
walletServiceErrorMsgListener = (ov, oldValue, newValue) -> {
|
walletServiceErrorMsgListener = (ov, oldValue, newValue) -> {
|
||||||
blockchainSyncLabel.setId("splash-error-state-msg");
|
btcSplashInfo.setId("splash-error-state-msg");
|
||||||
};
|
};
|
||||||
model.walletServiceErrorMsg.addListener(walletServiceErrorMsgListener);
|
model.walletServiceErrorMsg.addListener(walletServiceErrorMsgListener);
|
||||||
|
|
||||||
blockchainSyncIndicator = new ProgressBar(-1);
|
btcSyncIndicator = new ProgressBar(-1);
|
||||||
blockchainSyncIndicator.setPrefWidth(120);
|
btcSyncIndicator.setPrefWidth(120);
|
||||||
blockchainSyncIndicator.progressProperty().bind(model.blockchainSyncProgress);
|
btcSyncIndicator.progressProperty().bind(model.btcSyncProgress);
|
||||||
|
|
||||||
ImageView blockchainSyncIcon = new ImageView();
|
ImageView btcSyncIcon = new ImageView();
|
||||||
blockchainSyncIcon.setVisible(false);
|
btcSyncIcon.setVisible(false);
|
||||||
blockchainSyncIcon.setManaged(false);
|
btcSyncIcon.setManaged(false);
|
||||||
|
|
||||||
blockchainSyncIconIdListener = (ov, oldValue, newValue) -> {
|
btcSyncIconIdListener = (ov, oldValue, newValue) -> {
|
||||||
blockchainSyncIcon.setId(newValue);
|
btcSyncIcon.setId(newValue);
|
||||||
blockchainSyncIcon.setVisible(true);
|
btcSyncIcon.setVisible(true);
|
||||||
blockchainSyncIcon.setManaged(true);
|
btcSyncIcon.setManaged(true);
|
||||||
|
|
||||||
blockchainSyncIndicator.setVisible(false);
|
btcSyncIndicator.setVisible(false);
|
||||||
blockchainSyncIndicator.setManaged(false);
|
btcSyncIndicator.setManaged(false);
|
||||||
};
|
};
|
||||||
model.blockchainSyncIconId.addListener(blockchainSyncIconIdListener);
|
model.btcSplashSyncIconId.addListener(btcSyncIconIdListener);
|
||||||
|
|
||||||
Label bitcoinNetworkLabel = new Label();
|
|
||||||
bitcoinNetworkLabel.setText(model.bitcoinNetworkAsString);
|
|
||||||
bitcoinNetworkLabel.setId("splash-bitcoin-network-label");
|
|
||||||
|
|
||||||
HBox blockchainSyncBox = new HBox();
|
HBox blockchainSyncBox = new HBox();
|
||||||
blockchainSyncBox.setSpacing(10);
|
blockchainSyncBox.setSpacing(10);
|
||||||
blockchainSyncBox.setAlignment(Pos.CENTER);
|
blockchainSyncBox.setAlignment(Pos.CENTER);
|
||||||
blockchainSyncBox.setPadding(new Insets(40, 0, 0, 0));
|
blockchainSyncBox.setPadding(new Insets(40, 0, 0, 0));
|
||||||
blockchainSyncBox.setPrefHeight(50);
|
blockchainSyncBox.setPrefHeight(50);
|
||||||
blockchainSyncBox.getChildren().addAll(blockchainSyncLabel, blockchainSyncIndicator,
|
blockchainSyncBox.getChildren().addAll(btcSplashInfo, btcSyncIndicator, btcSyncIcon);
|
||||||
blockchainSyncIcon, bitcoinNetworkLabel);
|
|
||||||
|
|
||||||
|
|
||||||
// create P2PNetworkBox
|
// create P2PNetworkBox
|
||||||
|
@ -268,7 +264,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
splashP2PNetworkLabel.setWrapText(true);
|
splashP2PNetworkLabel.setWrapText(true);
|
||||||
splashP2PNetworkLabel.setMaxWidth(500);
|
splashP2PNetworkLabel.setMaxWidth(500);
|
||||||
splashP2PNetworkLabel.setTextAlignment(TextAlignment.CENTER);
|
splashP2PNetworkLabel.setTextAlignment(TextAlignment.CENTER);
|
||||||
splashP2PNetworkLabel.textProperty().bind(model.splashP2PNetworkInfo);
|
splashP2PNetworkLabel.textProperty().bind(model.p2PNetworkInfo);
|
||||||
|
|
||||||
splashP2PNetworkIndicator = new ProgressIndicator();
|
splashP2PNetworkIndicator = new ProgressIndicator();
|
||||||
splashP2PNetworkIndicator.setMaxSize(24, 24);
|
splashP2PNetworkIndicator.setMaxSize(24, 24);
|
||||||
|
@ -278,7 +274,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
splashP2PNetworkLabel.setId("splash-error-state-msg");
|
splashP2PNetworkLabel.setId("splash-error-state-msg");
|
||||||
splashP2PNetworkIndicator.setVisible(false);
|
splashP2PNetworkIndicator.setVisible(false);
|
||||||
};
|
};
|
||||||
model.p2PNetworkErrorMsg.addListener(splashP2PNetworkErrorMsgListener);
|
model.p2PNetworkWarnMsg.addListener(splashP2PNetworkErrorMsgListener);
|
||||||
|
|
||||||
|
|
||||||
ImageView splashP2PNetworkIcon = new ImageView();
|
ImageView splashP2PNetworkIcon = new ImageView();
|
||||||
|
@ -314,14 +310,14 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
|
|
||||||
private void disposeSplashScreen() {
|
private void disposeSplashScreen() {
|
||||||
model.walletServiceErrorMsg.removeListener(walletServiceErrorMsgListener);
|
model.walletServiceErrorMsg.removeListener(walletServiceErrorMsgListener);
|
||||||
model.blockchainSyncIconId.removeListener(blockchainSyncIconIdListener);
|
model.btcSplashSyncIconId.removeListener(btcSyncIconIdListener);
|
||||||
|
|
||||||
model.p2PNetworkErrorMsg.removeListener(splashP2PNetworkErrorMsgListener);
|
model.p2PNetworkWarnMsg.removeListener(splashP2PNetworkErrorMsgListener);
|
||||||
model.p2PNetworkIconId.removeListener(splashP2PNetworkIconIdListener);
|
model.p2PNetworkIconId.removeListener(splashP2PNetworkIconIdListener);
|
||||||
model.splashP2PNetworkProgress.removeListener(splashP2PNetworkProgressListener);
|
model.splashP2PNetworkProgress.removeListener(splashP2PNetworkProgressListener);
|
||||||
|
|
||||||
blockchainSyncLabel.textProperty().unbind();
|
btcSplashInfo.textProperty().unbind();
|
||||||
blockchainSyncIndicator.progressProperty().unbind();
|
btcSyncIndicator.progressProperty().unbind();
|
||||||
|
|
||||||
splashP2PNetworkLabel.textProperty().unbind();
|
splashP2PNetworkLabel.textProperty().unbind();
|
||||||
splashP2PNetworkIndicator.progressProperty().unbind();
|
splashP2PNetworkIndicator.progressProperty().unbind();
|
||||||
|
@ -340,30 +336,26 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
setTopAnchor(separator, 0d);
|
setTopAnchor(separator, 0d);
|
||||||
|
|
||||||
// BTC
|
// BTC
|
||||||
Label blockchainSyncLabel = new Label();
|
Label btcInfoLabel = new Label();
|
||||||
blockchainSyncLabel.setId("footer-pane");
|
btcInfoLabel.setId("footer-pane");
|
||||||
blockchainSyncLabel.textProperty().bind(model.blockchainSyncInfoFooter);
|
btcInfoLabel.textProperty().bind(model.btcFooterInfo);
|
||||||
|
|
||||||
ProgressBar blockchainSyncIndicator = new ProgressBar(-1);
|
ProgressBar blockchainSyncIndicator = new ProgressBar(-1);
|
||||||
blockchainSyncIndicator.setPrefWidth(120);
|
blockchainSyncIndicator.setPrefWidth(120);
|
||||||
blockchainSyncIndicator.setMaxHeight(10);
|
blockchainSyncIndicator.setMaxHeight(10);
|
||||||
blockchainSyncIndicator.progressProperty().bind(model.blockchainSyncProgress);
|
blockchainSyncIndicator.progressProperty().bind(model.btcSyncProgress);
|
||||||
|
|
||||||
Label bitcoinNetworkLabel = new Label();
|
|
||||||
bitcoinNetworkLabel.setText("/ Bitcoin network: " + model.bitcoinNetworkAsString);
|
|
||||||
|
|
||||||
model.walletServiceErrorMsg.addListener((ov, oldValue, newValue) -> {
|
model.walletServiceErrorMsg.addListener((ov, oldValue, newValue) -> {
|
||||||
if (newValue != null) {
|
if (newValue != null) {
|
||||||
bitcoinNetworkLabel.setId("splash-error-state-msg");
|
btcInfoLabel.setId("splash-error-state-msg");
|
||||||
bitcoinNetworkLabel.setText("/ Bitcoin network: Not connected");
|
new Popup().warning(newValue + "\nPlease check your internet connection or try to restart the application.")
|
||||||
openBTCConnectionErrorPopup(newValue);
|
.show();
|
||||||
} else {
|
} else {
|
||||||
bitcoinNetworkLabel.setId("footer-bitcoin-network-label");
|
btcInfoLabel.setId("footer-pane");
|
||||||
bitcoinNetworkLabel.setText("/ Bitcoin network: " + model.bitcoinNetworkAsString);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
model.blockchainSyncProgress.addListener((ov, oldValue, newValue) -> {
|
model.btcSyncProgress.addListener((ov, oldValue, newValue) -> {
|
||||||
if ((double) newValue >= 1) {
|
if ((double) newValue >= 1) {
|
||||||
blockchainSyncIndicator.setVisible(false);
|
blockchainSyncIndicator.setVisible(false);
|
||||||
blockchainSyncIndicator.setManaged(false);
|
blockchainSyncIndicator.setManaged(false);
|
||||||
|
@ -373,7 +365,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
HBox blockchainSyncBox = new HBox();
|
HBox blockchainSyncBox = new HBox();
|
||||||
blockchainSyncBox.setSpacing(10);
|
blockchainSyncBox.setSpacing(10);
|
||||||
blockchainSyncBox.setAlignment(Pos.CENTER);
|
blockchainSyncBox.setAlignment(Pos.CENTER);
|
||||||
blockchainSyncBox.getChildren().addAll(blockchainSyncLabel, blockchainSyncIndicator, bitcoinNetworkLabel);
|
blockchainSyncBox.getChildren().addAll(btcInfoLabel, blockchainSyncIndicator);
|
||||||
setLeftAnchor(blockchainSyncBox, 10d);
|
setLeftAnchor(blockchainSyncBox, 10d);
|
||||||
setBottomAnchor(blockchainSyncBox, 7d);
|
setBottomAnchor(blockchainSyncBox, 7d);
|
||||||
|
|
||||||
|
@ -401,15 +393,13 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
setBottomAnchor(p2PNetworkIcon, 7d);
|
setBottomAnchor(p2PNetworkIcon, 7d);
|
||||||
p2PNetworkIcon.idProperty().bind(model.p2PNetworkIconId);
|
p2PNetworkIcon.idProperty().bind(model.p2PNetworkIconId);
|
||||||
|
|
||||||
model.p2PNetworkErrorMsg.addListener((ov, oldValue, newValue) -> {
|
model.p2PNetworkWarnMsg.addListener((ov, oldValue, newValue) -> {
|
||||||
if (newValue != null) {
|
if (newValue != null) {
|
||||||
p2PNetworkLabel.setId("splash-error-state-msg");
|
p2PNetworkLabel.setId("splash-error-state-msg");
|
||||||
p2PNetworkLabel.textProperty().unbind();
|
new Popup().warning(newValue + "\nPlease check your internet connection or try to restart the application.")
|
||||||
new Popup().error("Connecting to the P2P network failed. \n" + newValue
|
.show();
|
||||||
+ "\nPlease check your internet connection.").show();
|
|
||||||
} else {
|
} else {
|
||||||
p2PNetworkLabel.setId("footer-pane");
|
p2PNetworkLabel.setId("footer-pane");
|
||||||
p2PNetworkLabel.textProperty().bind(model.p2PNetworkInfo);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -514,8 +504,4 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
||||||
throw new IllegalArgumentException("Cannot get ID for " + viewClass + ": class must end in " + suffix);
|
throw new IllegalArgumentException("Cannot get ID for " + viewClass + ": class must end in " + suffix);
|
||||||
return viewName.substring(0, suffixIdx).toLowerCase();
|
return viewName.substring(0, suffixIdx).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openBTCConnectionErrorPopup(String errorMsg) {
|
|
||||||
new Popup().error("Connecting to the bitcoin network failed. \n" + errorMsg).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -84,20 +84,18 @@ class MainViewModel implements ViewModel {
|
||||||
private final BSFormatter formatter;
|
private final BSFormatter formatter;
|
||||||
|
|
||||||
// BTC network
|
// BTC network
|
||||||
final StringProperty blockchainSyncInfo = new SimpleStringProperty("Initializing");
|
final StringProperty btcSplashInfo = new SimpleStringProperty("Initializing");
|
||||||
final StringProperty blockchainSyncInfoFooter = new SimpleStringProperty("Initializing");
|
final StringProperty btcFooterInfo = new SimpleStringProperty("Initializing");
|
||||||
final DoubleProperty blockchainSyncProgress = new SimpleDoubleProperty(-1);
|
final DoubleProperty btcSyncProgress = new SimpleDoubleProperty(-1);
|
||||||
final StringProperty walletServiceErrorMsg = new SimpleStringProperty();
|
final StringProperty walletServiceErrorMsg = new SimpleStringProperty();
|
||||||
final StringProperty blockchainSyncIconId = new SimpleStringProperty();
|
final StringProperty btcSplashSyncIconId = new SimpleStringProperty();
|
||||||
final StringProperty availableBalance = new SimpleStringProperty();
|
final StringProperty availableBalance = new SimpleStringProperty();
|
||||||
final StringProperty lockedBalance = new SimpleStringProperty();
|
final StringProperty lockedBalance = new SimpleStringProperty();
|
||||||
private final StringProperty numBTCPeersAsString = new SimpleStringProperty();
|
|
||||||
|
|
||||||
// P2P network
|
// P2P network
|
||||||
final StringProperty splashP2PNetworkInfo = new SimpleStringProperty();
|
|
||||||
final StringProperty p2PNetworkInfo = new SimpleStringProperty();
|
final StringProperty p2PNetworkInfo = new SimpleStringProperty();
|
||||||
final DoubleProperty splashP2PNetworkProgress = new SimpleDoubleProperty(-1);
|
final DoubleProperty splashP2PNetworkProgress = new SimpleDoubleProperty(-1);
|
||||||
final StringProperty p2PNetworkErrorMsg = new SimpleStringProperty();
|
final StringProperty p2PNetworkWarnMsg = new SimpleStringProperty();
|
||||||
final StringProperty p2PNetworkIconId = new SimpleStringProperty();
|
final StringProperty p2PNetworkIconId = new SimpleStringProperty();
|
||||||
|
|
||||||
// software update
|
// software update
|
||||||
|
@ -109,8 +107,8 @@ class MainViewModel implements ViewModel {
|
||||||
final StringProperty numOpenDisputesAsString = new SimpleStringProperty();
|
final StringProperty numOpenDisputesAsString = new SimpleStringProperty();
|
||||||
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;
|
||||||
|
|
||||||
final String bitcoinNetworkAsString;
|
|
||||||
|
|
||||||
private Timer blockchainSyncTimeoutTimer;
|
private Timer blockchainSyncTimeoutTimer;
|
||||||
private Timer lostP2PConnectionTimeoutTimer;
|
private Timer lostP2PConnectionTimeoutTimer;
|
||||||
|
@ -144,7 +142,7 @@ class MainViewModel implements ViewModel {
|
||||||
this.walletPasswordPopup = walletPasswordPopup;
|
this.walletPasswordPopup = walletPasswordPopup;
|
||||||
this.formatter = formatter;
|
this.formatter = formatter;
|
||||||
|
|
||||||
bitcoinNetworkAsString = formatter.formatBitcoinNetwork(preferences.getBitcoinNetwork());
|
btcNetworkAsString = formatter.formatBitcoinNetwork(preferences.getBitcoinNetwork());
|
||||||
|
|
||||||
TxIdTextField.setPreferences(preferences);
|
TxIdTextField.setPreferences(preferences);
|
||||||
TxIdTextField.setWalletService(walletService);
|
TxIdTextField.setWalletService(walletService);
|
||||||
|
@ -185,49 +183,46 @@ class MainViewModel implements ViewModel {
|
||||||
|
|
||||||
private BooleanProperty initP2PNetwork() {
|
private BooleanProperty initP2PNetwork() {
|
||||||
final BooleanProperty p2pNetWorkReady = new SimpleBooleanProperty();
|
final BooleanProperty p2pNetWorkReady = new SimpleBooleanProperty();
|
||||||
splashP2PNetworkInfo.set("Connecting to Tor network...");
|
p2PNetworkInfo.set("Connecting to Tor network...");
|
||||||
p2PService.start(new P2PServiceListener() {
|
p2PService.start(new P2PServiceListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTorNodeReady() {
|
public void onTorNodeReady() {
|
||||||
splashP2PNetworkInfo.set("Tor node created.");
|
p2PNetworkInfo.set("Tor node created");
|
||||||
p2PNetworkInfo.set(splashP2PNetworkInfo.get());
|
|
||||||
p2PNetworkIconId.set("image-connection-tor");
|
p2PNetworkIconId.set("image-connection-tor");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHiddenServicePublished() {
|
public void onHiddenServicePublished() {
|
||||||
splashP2PNetworkInfo.set("Hidden Service published.");
|
p2PNetworkInfo.set("Hidden Service published");
|
||||||
p2PNetworkInfo.set(splashP2PNetworkInfo.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestingDataCompleted() {
|
public void onRequestingDataCompleted() {
|
||||||
if (p2PService.getNumAuthenticatedPeers().get() == 0) {
|
if (p2PService.getNumAuthenticatedPeers().get() == 0) {
|
||||||
splashP2PNetworkInfo.set("Initial data received.");
|
p2PNetworkInfo.set("Initial data received");
|
||||||
p2PNetworkInfo.set(splashP2PNetworkInfo.get());
|
|
||||||
} else {
|
} else {
|
||||||
updateP2pNetworkInfo();
|
updateP2pNetworkInfoWithPeersChanged(p2PService.getNumAuthenticatedPeers().get());
|
||||||
}
|
}
|
||||||
p2pNetWorkReady.set(true);
|
p2pNetWorkReady.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNoSeedNodeAvailable() {
|
public void onNoSeedNodeAvailable() {
|
||||||
splashP2PNetworkInfo.set("No seed node available.");
|
p2PNetworkWarnMsg.set("There are no seed nodes available.");
|
||||||
p2PNetworkInfo.set(splashP2PNetworkInfo.get());
|
p2PNetworkInfo.set("No seed node available");
|
||||||
p2pNetWorkReady.set(true);
|
p2pNetWorkReady.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFirstPeerAuthenticated() {
|
public void onFirstPeerAuthenticated() {
|
||||||
updateP2pNetworkInfo();
|
updateP2pNetworkInfoWithPeersChanged(p2PService.getNumAuthenticatedPeers().get());
|
||||||
splashP2PNetworkProgress.set(1);
|
splashP2PNetworkProgress.set(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetupFailed(Throwable throwable) {
|
public void onSetupFailed(Throwable throwable) {
|
||||||
p2PNetworkErrorMsg.set("Connecting to the P2P network failed. " + throwable.getMessage());
|
p2PNetworkWarnMsg.set("Connecting to the P2P network failed (reported error: " + throwable.getMessage() + ").");
|
||||||
splashP2PNetworkProgress.set(0);
|
splashP2PNetworkProgress.set(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -241,35 +236,16 @@ class MainViewModel implements ViewModel {
|
||||||
|
|
||||||
EasyBind.subscribe(walletService.downloadPercentageProperty(), newValue -> setBitcoinNetworkSyncProgress((double) newValue));
|
EasyBind.subscribe(walletService.downloadPercentageProperty(), newValue -> setBitcoinNetworkSyncProgress((double) newValue));
|
||||||
|
|
||||||
/* walletService.downloadPercentageProperty().addListener((ov, oldValue, newValue) -> {
|
|
||||||
setBitcoinNetworkSyncProgress((double) newValue);
|
|
||||||
});
|
|
||||||
setBitcoinNetworkSyncProgress(walletService.downloadPercentageProperty().get());
|
|
||||||
// Sometimes we don't get the updates, so add an additional setter after 2 seconds
|
|
||||||
FxTimer.runLater(Duration.ofMillis(2000), () -> setBitcoinNetworkSyncProgress(walletService.downloadPercentageProperty().get()));*/
|
|
||||||
|
|
||||||
walletService.numPeersProperty().addListener((observable, oldValue, newValue) -> {
|
walletService.numPeersProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
numBTCPeers = (int) newValue;
|
if ((int) oldValue > 0 && (int) newValue == 0)
|
||||||
numBTCPeersAsString.set(String.valueOf(newValue) + " peers");
|
walletServiceErrorMsg.set("You lost the connection to all bitcoin peers.");
|
||||||
if (blockchainSyncProgress.get() >= 1 && numBTCPeers > 0)
|
else if ((int) oldValue == 0 && (int) newValue > 0)
|
||||||
blockchainSyncInfoFooter.set("Bitcoin network: Peers: " + numBTCPeers);
|
|
||||||
|
|
||||||
/* if ((int) newValue < 1) {
|
|
||||||
if (lostBTCConnectionTimeoutTimer != null)
|
|
||||||
lostBTCConnectionTimeoutTimer.cancel();
|
|
||||||
lostBTCConnectionTimeoutTimer = Utilities.setTimeout(LOST_BTC_CONNECTION_TIMEOUT, () -> {
|
|
||||||
log.trace("Connection lost timeout reached");
|
|
||||||
walletServiceErrorMsg.set("We lost connection to the last peer.");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (lostBTCConnectionTimeoutTimer != null) {
|
|
||||||
lostBTCConnectionTimeoutTimer.cancel();
|
|
||||||
lostBTCConnectionTimeoutTimer = null;
|
|
||||||
}
|
|
||||||
walletServiceErrorMsg.set(null);
|
walletServiceErrorMsg.set(null);
|
||||||
}*/
|
|
||||||
|
numBTCPeers = (int) newValue;
|
||||||
|
setBitcoinNetworkSyncProgress(walletService.downloadPercentageProperty().get());
|
||||||
});
|
});
|
||||||
|
|
||||||
final BooleanProperty walletInitialized = new SimpleBooleanProperty();
|
final BooleanProperty walletInitialized = new SimpleBooleanProperty();
|
||||||
walletService.initialize(null,
|
walletService.initialize(null,
|
||||||
() -> {
|
() -> {
|
||||||
|
@ -374,14 +350,21 @@ class MainViewModel implements ViewModel {
|
||||||
.show();
|
.show();
|
||||||
|
|
||||||
// update nr of peers in footer
|
// update nr of peers in footer
|
||||||
p2PService.getNumAuthenticatedPeers().addListener((observable, oldValue, newValue) -> updateP2pNetworkInfo());
|
p2PService.getNumAuthenticatedPeers().addListener((observable, oldValue, newValue) -> {
|
||||||
|
if ((int) oldValue > 0 && (int) newValue == 0)
|
||||||
|
p2PNetworkWarnMsg.set("You lost the connection to all P2P network peers.");
|
||||||
|
else if ((int) oldValue == 0 && (int) newValue > 0)
|
||||||
|
p2PNetworkWarnMsg.set(null);
|
||||||
|
|
||||||
|
updateP2pNetworkInfoWithPeersChanged((int) newValue);
|
||||||
|
});
|
||||||
|
|
||||||
// now show app
|
// now show app
|
||||||
showAppScreen.set(true);
|
showAppScreen.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateP2pNetworkInfo() {
|
private void updateP2pNetworkInfoWithPeersChanged(int numAuthenticatedPeers) {
|
||||||
p2PNetworkInfo.set("Nr. of authenticated connections: " + p2PService.getNumAuthenticatedPeers().get());
|
p2PNetworkInfo.set("Nr. of connections: " + numAuthenticatedPeers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayAlertIfPresent(Alert alert) {
|
private void displayAlertIfPresent(Alert alert) {
|
||||||
|
@ -479,18 +462,16 @@ class MainViewModel implements ViewModel {
|
||||||
|
|
||||||
private void setWalletServiceException(Throwable error) {
|
private void setWalletServiceException(Throwable error) {
|
||||||
setBitcoinNetworkSyncProgress(0);
|
setBitcoinNetworkSyncProgress(0);
|
||||||
blockchainSyncInfo.set("Connecting to the bitcoin network failed.");
|
btcSplashInfo.set("Nr. of peers: " + numBTCPeers + " / connecting to " + btcNetworkAsString + " failed");
|
||||||
blockchainSyncInfoFooter.set("Connection failed.");
|
btcFooterInfo.set("Nr. of eers: " + numBTCPeers + " / connecting to " + btcNetworkAsString + " failed");
|
||||||
if (error instanceof TimeoutException) {
|
if (error instanceof TimeoutException) {
|
||||||
walletServiceErrorMsg.set("Please check your network connection.\n\n" +
|
walletServiceErrorMsg.set("Connecting to the bitcoin network failed because of a timeout.");
|
||||||
"You must allow outgoing TCP connections to port 18333 for the bitcoin testnet.\n\n" +
|
|
||||||
"See https://github.com/bitsquare/bitsquare/wiki for instructions.");
|
|
||||||
} else if (error.getCause() instanceof BlockStoreException) {
|
} else if (error.getCause() instanceof BlockStoreException) {
|
||||||
walletServiceErrorMsg.set("You cannot run 2 instances of the program.");
|
walletServiceErrorMsg.set("Bitsquare is already running. You cannot run 2 instances of Bitsquare.");
|
||||||
} else if (error.getMessage() != null) {
|
} else if (error.getMessage() != null) {
|
||||||
walletServiceErrorMsg.set(error.getMessage());
|
walletServiceErrorMsg.set("Connection to the bitcoin network failed because of an error:" + error.getMessage());
|
||||||
} else {
|
} else {
|
||||||
walletServiceErrorMsg.set(error.toString());
|
walletServiceErrorMsg.set("Connection to the bitcoin network failed because of an error:" + error.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,27 +561,24 @@ class MainViewModel implements ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBitcoinNetworkSyncProgress(double value) {
|
private void setBitcoinNetworkSyncProgress(double value) {
|
||||||
blockchainSyncProgress.set(value);
|
btcSyncProgress.set(value);
|
||||||
String nrOfPeers = "";
|
String numPeers = "Nr. of peers: " + numBTCPeers;
|
||||||
if (numBTCPeers > 1)
|
|
||||||
nrOfPeers = ", Peers: " + numBTCPeers;
|
|
||||||
|
|
||||||
if (value >= 1) {
|
if (value >= 1) {
|
||||||
stopBlockchainSyncTimeout();
|
stopBlockchainSyncTimeout();
|
||||||
|
btcSplashInfo.set(numPeers + " / synchronized with " + btcNetworkAsString);
|
||||||
blockchainSyncInfo.set("Blockchain synchronization complete." + nrOfPeers);
|
btcFooterInfo.set(numPeers + " / synchronized with " + btcNetworkAsString);
|
||||||
blockchainSyncIconId.set("image-connection-synced");
|
btcSplashSyncIconId.set("image-connection-synced");
|
||||||
blockchainSyncInfoFooter.set("Bitcoin network: Peers: " + numBTCPeers);
|
|
||||||
} else if (value > 0.0) {
|
} else if (value > 0.0) {
|
||||||
// We stop as soon the download started the timeout
|
// We stop as soon the download started the timeout
|
||||||
stopBlockchainSyncTimeout();
|
stopBlockchainSyncTimeout();
|
||||||
|
|
||||||
blockchainSyncInfo.set("Synchronizing blockchain: " + formatter.formatToPercent(value) + nrOfPeers);
|
String percentage = formatter.formatToPercent(value);
|
||||||
blockchainSyncInfoFooter.set("Synchronizing: " + formatter.formatToPercent(value) + nrOfPeers);
|
btcSplashInfo.set(numPeers + " / synchronizing with " + btcNetworkAsString + ": " + percentage);
|
||||||
|
btcFooterInfo.set(numPeers + " / synchronizing " + btcNetworkAsString + ": " + percentage);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
blockchainSyncInfo.set("Connecting to the bitcoin network..." + nrOfPeers);
|
btcSplashInfo.set(numPeers + " / connecting to " + btcNetworkAsString);
|
||||||
blockchainSyncInfoFooter.set("Connecting..." + nrOfPeers);
|
btcFooterInfo.set(numPeers + " / connecting to " + btcNetworkAsString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,6 +141,11 @@ public class Popup {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Popup hideReportErrorButtons() {
|
||||||
|
this.showReportErrorButtons = false;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Popup message(String message) {
|
public Popup message(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
setTruncatedMessage();
|
setTruncatedMessage();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue