Include "blocks remaining" in systray when syncing from more than 60 minutes away from a peer's chain tip.

This commit is contained in:
CalDescent 2022-10-28 16:57:52 +01:00
parent b64c053531
commit 59a804c560
16 changed files with 60 additions and 0 deletions

View File

@ -838,6 +838,12 @@ public class Controller extends Thread {
String tooltip = String.format("%s - %d %s", actionText, numberOfPeers, connectionsText);
if (!Settings.getInstance().isLite()) {
tooltip = tooltip.concat(String.format(" - %s %d", heightText, height));
final Integer blocksRemaining = Synchronizer.getInstance().getBlocksRemaining();
if (blocksRemaining != null && blocksRemaining > 0) {
String blocksRemainingText = Translator.INSTANCE.translate("SysTray", "BLOCKS_REMAINING");
tooltip = tooltip.concat(String.format(" - %d %s", blocksRemaining, blocksRemainingText));
}
}
tooltip = tooltip.concat(String.format("\n%s: %s", Translator.INSTANCE.translate("SysTray", "BUILD_VERSION"), this.buildVersion));
SysTray.getInstance().setToolTipText(tooltip);

View File

@ -76,6 +76,8 @@ public class Synchronizer extends Thread {
private volatile boolean isSynchronizing = false;
/** Temporary estimate of synchronization progress for SysTray use. */
private volatile int syncPercent = 0;
/** Temporary estimate of blocks remaining for SysTray use. */
private volatile int blocksRemaining = 0;
private static volatile boolean requestSync = false;
private boolean syncRequestPending = false;
@ -181,6 +183,18 @@ public class Synchronizer extends Thread {
}
}
public Integer getBlocksRemaining() {
synchronized (this.syncLock) {
// Report as 0 blocks remaining if the latest block is within the last 60 mins
final Long minLatestBlockTimestamp = NTP.getTime() - (60 * 60 * 1000L);
if (Controller.getInstance().isUpToDate(minLatestBlockTimestamp)) {
return 0;
}
return this.isSynchronizing ? this.blocksRemaining : null;
}
}
public void requestSync() {
requestSync = true;
}
@ -1457,6 +1471,12 @@ public class Synchronizer extends Thread {
repository.saveChanges();
synchronized (this.syncLock) {
if (peer.getChainTipData() != null) {
this.blocksRemaining = peer.getChainTipData().getHeight() - newBlock.getBlockData().getHeight();
}
}
Controller.getInstance().onNewBlock(newBlock.getBlockData());
}
@ -1552,6 +1572,12 @@ public class Synchronizer extends Thread {
repository.saveChanges();
synchronized (this.syncLock) {
if (peer.getChainTipData() != null) {
this.blocksRemaining = peer.getChainTipData().getHeight() - newBlock.getBlockData().getHeight();
}
}
Controller.getInstance().onNewBlock(newBlock.getBlockData());
}

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = Automatisches Update
BLOCK_HEIGHT = height
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = Build-Version
CHECK_TIME_ACCURACY = Prüfe Zeitgenauigkeit

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = Auto Update
BLOCK_HEIGHT = height
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = Build version
CHECK_TIME_ACCURACY = Check time accuracy

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = Actualización automática
BLOCK_HEIGHT = altura
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = Versión de compilación
CHECK_TIME_ACCURACY = Comprobar la precisión del tiempo

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = Automaattinen päivitys
BLOCK_HEIGHT = korkeus
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = Versio
CHECK_TIME_ACCURACY = Tarkista ajan tarkkuus

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = Mise à jour automatique
BLOCK_HEIGHT = hauteur
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = Numéro de version
CHECK_TIME_ACCURACY = Vérifier l'heure

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = Automatikus Frissítés
BLOCK_HEIGHT = blokkmagasság
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = Verzió
CHECK_TIME_ACCURACY = Óra pontosságának ellenőrzése

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = Aggiornamento automatico
BLOCK_HEIGHT = altezza
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = Versione
CHECK_TIME_ACCURACY = Controlla la precisione dell'ora

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = 자동 업데이트
BLOCK_HEIGHT = 높이
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = 빌드 버전
CHECK_TIME_ACCURACY = 시간 정확도 점검

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = Automatische Update
BLOCK_HEIGHT = Block hoogte
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = Versie nummer
CHECK_TIME_ACCURACY = Controleer accuraatheid van de tijd

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = Actualizare automata
BLOCK_HEIGHT = dimensiune
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = versiunea compilatiei
CHECK_TIME_ACCURACY = verificare exactitate ora

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = Автоматическое обновление
BLOCK_HEIGHT = Высота блока
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = Версия сборки
CHECK_TIME_ACCURACY = Проверка точного времени

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = Automatisk uppdatering
BLOCK_HEIGHT = höjd
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = Byggversion
CHECK_TIME_ACCURACY = Kontrollera tidens noggrannhet

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = 自动更新
BLOCK_HEIGHT = 区块高度
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = 版本
CHECK_TIME_ACCURACY = 检查时间准确性

View File

@ -7,6 +7,8 @@ AUTO_UPDATE = 自動更新
BLOCK_HEIGHT = 區塊高度
BLOCKS_REMAINING = blocks remaining
BUILD_VERSION = 版本
CHECK_TIME_ACCURACY = 檢查時間準確性