mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
add block height to terminal connected label
This commit is contained in:
parent
3cbe8d1537
commit
ff90a2c3e6
1 changed files with 14 additions and 5 deletions
|
@ -67,9 +67,13 @@ public class SparrowTextGui extends MultiWindowTextGUI {
|
|||
return mainWindow;
|
||||
}
|
||||
|
||||
private void setConnectedLabel(boolean connected) {
|
||||
private void setDisconnectedLabel() {
|
||||
setConnectedLabel(null);
|
||||
}
|
||||
|
||||
private void setConnectedLabel(Integer height) {
|
||||
getGUIThread().invokeLater(() -> {
|
||||
connectedLabel.setText(connected ? "Connected" : "Disconnected");
|
||||
connectedLabel.setText(height == null ? "Disconnected" : "Connected at " + height);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -80,24 +84,29 @@ public class SparrowTextGui extends MultiWindowTextGUI {
|
|||
|
||||
@Subscribe
|
||||
public void connectionFailed(ConnectionFailedEvent event) {
|
||||
setConnectedLabel(false);
|
||||
setDisconnectedLabel();
|
||||
statusUpdated(new StatusEvent("Connection failed: " + event.getMessage()));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void connection(ConnectionEvent event) {
|
||||
setConnectedLabel(true);
|
||||
setConnectedLabel(event.getBlockHeight());
|
||||
statusUpdated(new StatusEvent("Connected to " + Config.get().getServerDisplayName() + " at height " + event.getBlockHeight()));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void disconnection(DisconnectionEvent event) {
|
||||
if(!AppServices.isConnecting() && !AppServices.isConnected()) {
|
||||
setConnectedLabel(false);
|
||||
setDisconnectedLabel();
|
||||
statusUpdated(new StatusEvent("Disconnected"));
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void newBlock(NewBlockEvent event) {
|
||||
setConnectedLabel(event.getHeight());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void statusUpdated(StatusEvent event) {
|
||||
getGUIThread().invokeLater(() -> statusLabel.setText(event.getStatus()));
|
||||
|
|
Loading…
Reference in a new issue