forked from Qortal/qortal
More descriptive tray mouseover, showing sync percent or connecting status
Added sync percent to API call GET /admin/status Added SysTray i18n "CONNECTING" key to CheckTranslations test app.
This commit is contained in:
parent
2ddb1fa23e
commit
d90d84ab06
@ -9,6 +9,9 @@ public class NodeStatus {
|
||||
public boolean isMintingPossible;
|
||||
public boolean isSynchronizing;
|
||||
|
||||
// Not always present
|
||||
public Integer syncPercent;
|
||||
|
||||
public NodeStatus() {
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,9 @@ public class AdminResource {
|
||||
nodeStatus.isMintingPossible = Controller.getInstance().isMintingPossible();
|
||||
nodeStatus.isSynchronizing = Controller.getInstance().isSynchronizing();
|
||||
|
||||
if (nodeStatus.isSynchronizing)
|
||||
nodeStatus.syncPercent = Controller.getInstance().getSyncPercent();
|
||||
|
||||
return nodeStatus;
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,8 @@ public class Controller extends Thread {
|
||||
|
||||
/** Whether we are attempting to synchronize. */
|
||||
private volatile boolean isSynchronizing = false;
|
||||
/** Temporary estimate of synchronization progress for SysTray use. */
|
||||
private volatile int syncPercent = 0;
|
||||
|
||||
/** Latest block signatures from other peers that we know are on inferior chains. */
|
||||
List<ByteArray> inferiorChainSignatures = new ArrayList<>();
|
||||
@ -258,6 +260,10 @@ public class Controller extends Thread {
|
||||
return this.isSynchronizing;
|
||||
}
|
||||
|
||||
public Integer getSyncPercent() {
|
||||
return this.isSynchronizing ? this.syncPercent : null;
|
||||
}
|
||||
|
||||
// Entry point
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ -522,6 +528,7 @@ public class Controller extends Thread {
|
||||
int index = new SecureRandom().nextInt(peers.size());
|
||||
Peer peer = peers.get(index);
|
||||
|
||||
syncPercent = (this.chainTip.getHeight() * 100) / peer.getChainTipData().getLastHeight();
|
||||
isSynchronizing = true;
|
||||
updateSysTray();
|
||||
|
||||
@ -633,14 +640,15 @@ public class Controller extends Thread {
|
||||
String connectionsText = Translator.INSTANCE.translate("SysTray", numberOfPeers != 1 ? "CONNECTIONS" : "CONNECTION");
|
||||
String heightText = Translator.INSTANCE.translate("SysTray", "BLOCK_HEIGHT");
|
||||
|
||||
String actionKey;
|
||||
String actionText;
|
||||
if (isMintingPossible)
|
||||
actionKey = "MINTING_ENABLED";
|
||||
actionText = Translator.INSTANCE.translate("SysTray", "MINTING_ENABLED");
|
||||
else if (isSynchronizing)
|
||||
actionKey = "SYNCHRONIZING_BLOCKCHAIN";
|
||||
actionText = String.format("%s - %d%%", Translator.INSTANCE.translate("SysTray", "SYNCHRONIZING_BLOCKCHAIN"), syncPercent);
|
||||
else if (numberOfPeers < Settings.getInstance().getMinBlockchainPeers())
|
||||
actionText = Translator.INSTANCE.translate("SysTray", "CONNECTING");
|
||||
else
|
||||
actionKey = "MINTING_DISABLED";
|
||||
String actionText = Translator.INSTANCE.translate("SysTray", actionKey);
|
||||
actionText = Translator.INSTANCE.translate("SysTray", "MINTING_DISABLED");
|
||||
|
||||
String tooltip = String.format("%s - %d %s - %s %d", actionText, numberOfPeers, connectionsText, heightText, height);
|
||||
SysTray.getInstance().setToolTipText(tooltip);
|
||||
|
@ -9,6 +9,8 @@ BLOCK_HEIGHT = height
|
||||
|
||||
CHECK_TIME_ACCURACY = Check time accuracy
|
||||
|
||||
CONNECTING = Connecting
|
||||
|
||||
CONNECTION = connection
|
||||
|
||||
CONNECTIONS = connections
|
||||
|
@ -14,7 +14,7 @@ public class CheckTranslations {
|
||||
|
||||
private static final String[] SUPPORTED_LANGS = new String[] { "en", "de", "zh", "ru" };
|
||||
private static final Set<String> SYSTRAY_KEYS = Set.of("AUTO_UPDATE", "APPLYING_UPDATE_AND_RESTARTING", "BLOCK_HEIGHT",
|
||||
"CHECK_TIME_ACCURACY", "CONNECTION", "CONNECTIONS", "CREATING_BACKUP_OF_DB_FILES", "DB_BACKUP", "EXIT",
|
||||
"CHECK_TIME_ACCURACY", "CONNECTING", "CONNECTION", "CONNECTIONS", "CREATING_BACKUP_OF_DB_FILES", "DB_BACKUP", "EXIT",
|
||||
"MINTING_DISABLED", "MINTING_ENABLED", "NTP_NAG_CAPTION", "NTP_NAG_TEXT_UNIX", "NTP_NAG_TEXT_WINDOWS",
|
||||
"OPEN_UI", "SYNCHRONIZE_CLOCK", "SYNCHRONIZING_BLOCKCHAIN", "SYNCHRONIZING_CLOCK");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user