mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +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;
|
return mainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setConnectedLabel(boolean connected) {
|
private void setDisconnectedLabel() {
|
||||||
|
setConnectedLabel(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setConnectedLabel(Integer height) {
|
||||||
getGUIThread().invokeLater(() -> {
|
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
|
@Subscribe
|
||||||
public void connectionFailed(ConnectionFailedEvent event) {
|
public void connectionFailed(ConnectionFailedEvent event) {
|
||||||
setConnectedLabel(false);
|
setDisconnectedLabel();
|
||||||
statusUpdated(new StatusEvent("Connection failed: " + event.getMessage()));
|
statusUpdated(new StatusEvent("Connection failed: " + event.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void connection(ConnectionEvent event) {
|
public void connection(ConnectionEvent event) {
|
||||||
setConnectedLabel(true);
|
setConnectedLabel(event.getBlockHeight());
|
||||||
statusUpdated(new StatusEvent("Connected to " + Config.get().getServerDisplayName() + " at height " + event.getBlockHeight()));
|
statusUpdated(new StatusEvent("Connected to " + Config.get().getServerDisplayName() + " at height " + event.getBlockHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void disconnection(DisconnectionEvent event) {
|
public void disconnection(DisconnectionEvent event) {
|
||||||
if(!AppServices.isConnecting() && !AppServices.isConnected()) {
|
if(!AppServices.isConnecting() && !AppServices.isConnected()) {
|
||||||
setConnectedLabel(false);
|
setDisconnectedLabel();
|
||||||
statusUpdated(new StatusEvent("Disconnected"));
|
statusUpdated(new StatusEvent("Disconnected"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void newBlock(NewBlockEvent event) {
|
||||||
|
setConnectedLabel(event.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void statusUpdated(StatusEvent event) {
|
public void statusUpdated(StatusEvent event) {
|
||||||
getGUIThread().invokeLater(() -> statusLabel.setText(event.getStatus()));
|
getGUIThread().invokeLater(() -> statusLabel.setText(event.getStatus()));
|
||||||
|
|
Loading…
Reference in a new issue