show that wallet is syncing on startup

This commit is contained in:
woodser 2023-11-28 13:38:32 -05:00
parent 9fb22f6d1f
commit 84c08e4c36
20 changed files with 75 additions and 50 deletions

View file

@ -569,7 +569,7 @@ public final class XmrConnectionService {
long targetHeight = lastInfo.getTargetHeight();
long blocksLeft = targetHeight - lastInfo.getHeight();
if (syncStartHeight == null) syncStartHeight = lastInfo.getHeight();
double percent = ((double) Math.max(1, lastInfo.getHeight() - syncStartHeight) / (double) (targetHeight - syncStartHeight)) * 100d; // grant at least 1 block to show progress
double percent = targetHeight == syncStartHeight ? 1.0 : ((double) Math.max(1, lastInfo.getHeight() - syncStartHeight) / (double) (targetHeight - syncStartHeight)) * 100d; // grant at least 1 block to show progress
downloadListener.progress(percent, blocksLeft, null);
}

View file

@ -401,6 +401,7 @@ public class HavenoSetup {
// reset startup timeout on progress
getXmrDaemonSyncProgress().addListener((observable, oldValue, newValue) -> resetStartupTimeout());
getXmrWalletSyncProgress().addListener((observable, oldValue, newValue) -> resetStartupTimeout());
log.info("Init P2P network");
havenoSetupListeners.forEach(HavenoSetupListener::onInitP2pNetwork);
@ -727,6 +728,10 @@ public class HavenoSetup {
return walletAppSetup.getXmrDaemonSyncProgress();
}
public DoubleProperty getXmrWalletSyncProgress() {
return walletAppSetup.getXmrWalletSyncProgress();
}
public StringProperty getWalletServiceErrorMsg() {
return walletAppSetup.getWalletServiceErrorMsg();
}

View file

@ -71,6 +71,8 @@ public class WalletAppSetup {
@Getter
private final DoubleProperty xmrDaemonSyncProgress = new SimpleDoubleProperty(-1);
@Getter
private final DoubleProperty xmrWalletSyncProgress = new SimpleDoubleProperty(-1);
@Getter
private final StringProperty walletServiceErrorMsg = new SimpleStringProperty();
@Getter
private final StringProperty xmrSplashSyncIconId = new SimpleStringProperty();
@ -117,29 +119,42 @@ public class WalletAppSetup {
String result;
if (exception == null && errorMsg == null) {
// TODO: update for daemon and wallet sync progress
double chainDownloadPercentageD = (double) chainDownloadPercentage;
xmrDaemonSyncProgress.set(chainDownloadPercentageD);
Long bestChainHeight = chainHeight == null ? null : (Long) chainHeight;
String chainHeightAsString = bestChainHeight != null && bestChainHeight > 0 ?
String.valueOf(bestChainHeight) :
"";
if (chainDownloadPercentageD == 1) {
String synchronizedWith = Res.get("mainView.footer.xmrInfo.synchronizedWith",
getXmrNetworkAsString(), chainHeightAsString);
// update wallet sync progress
double walletDownloadPercentageD = (double) walletDownloadPercentage;
xmrWalletSyncProgress.set(walletDownloadPercentageD);
Long bestWalletHeight = walletHeight == null ? null : (Long) walletHeight;
String walletHeightAsString = bestWalletHeight != null && bestWalletHeight > 0 ? String.valueOf(bestWalletHeight) : "";
if (walletDownloadPercentageD == 1) {
String synchronizedWith = Res.get("mainView.footer.xmrInfo.synchronizedWalletWith", getXmrNetworkAsString(), walletHeightAsString);
String feeInfo = ""; // TODO: feeService.isFeeAvailable() returns true, disable
result = Res.get("mainView.footer.xmrInfo", synchronizedWith, feeInfo);
getXmrSplashSyncIconId().set("image-connection-synced");
downloadCompleteHandler.run();
} else if (chainDownloadPercentageD > 0.0) {
String synchronizingWith = Res.get("mainView.footer.xmrInfo.synchronizingWith",
getXmrNetworkAsString(), chainHeightAsString,
FormattingUtils.formatToRoundedPercentWithSymbol(chainDownloadPercentageD));
result = Res.get("mainView.footer.xmrInfo", synchronizingWith, "");
} else if (walletDownloadPercentageD > 0) {
result = "Synchronizing wallet ..."; // TODO: support wallet progress updates and use below translation
// String synchronizingWith = Res.get("mainView.footer.xmrInfo.synchronizingWalletWith", getXmrNetworkAsString(), walletHeightAsString, FormattingUtils.formatToRoundedPercentWithSymbol(walletDownloadPercentageD));
// result = Res.get("mainView.footer.xmrInfo", synchronizingWith, "");
getXmrSplashSyncIconId().set(""); // clear synced icon
} else {
result = Res.get("mainView.footer.xmrInfo",
Res.get("mainView.footer.xmrInfo.connectingTo"),
getXmrNetworkAsString());
// update daemon sync progress
double chainDownloadPercentageD = (double) chainDownloadPercentage;
xmrDaemonSyncProgress.set(chainDownloadPercentageD);
Long bestChainHeight = chainHeight == null ? null : (Long) chainHeight;
String chainHeightAsString = bestChainHeight != null && bestChainHeight > 0 ? String.valueOf(bestChainHeight) : "";
if (chainDownloadPercentageD == 1) {
String synchronizedWith = Res.get("mainView.footer.xmrInfo.synchronizedDaemonWith", getXmrNetworkAsString(), chainHeightAsString);
String feeInfo = ""; // TODO: feeService.isFeeAvailable() returns true, disable
result = Res.get("mainView.footer.xmrInfo", synchronizedWith, feeInfo);
getXmrSplashSyncIconId().set("image-connection-synced");
} else if (chainDownloadPercentageD > 0.0) {
String synchronizingWith = Res.get("mainView.footer.xmrInfo.synchronizingDaemonWith", getXmrNetworkAsString(), chainHeightAsString, FormattingUtils.formatToRoundedPercentWithSymbol(chainDownloadPercentageD));
result = Res.get("mainView.footer.xmrInfo", synchronizingWith, "");
} else {
result = Res.get("mainView.footer.xmrInfo",
Res.get("mainView.footer.xmrInfo.connectingTo"),
getXmrNetworkAsString());
}
}
} else {
result = Res.get("mainView.footer.xmrInfo",

View file

@ -125,6 +125,7 @@ public class XmrWalletService {
private final Map<String, Optional<MoneroTx>> txCache = new HashMap<String, Optional<MoneroTx>>();
private boolean isShutDownStarted = false;
private ExecutorService syncWalletThreadPool = Executors.newFixedThreadPool(10); // TODO: adjust based on connection type
private Long syncStartHeight = null;
@Inject
XmrWalletService(Preferences preferences,
@ -724,9 +725,10 @@ public class XmrWalletService {
// sync main wallet if applicable
if (sync && numAttempts > 0) {
try {
// sync main wallet
log.info("Syncing main wallet");
updateSyncProgress();
long time = System.currentTimeMillis();
wallet.sync(); // blocking
walletHeight.set(wallet.getHeight());
@ -775,6 +777,15 @@ public class XmrWalletService {
}
}
private void updateSyncProgress() {
walletHeight.set(wallet.getHeight());
long targetHeight = xmrConnectionService.getTargetHeight();
long blocksLeft = targetHeight - walletHeight.get();
if (syncStartHeight == null) syncStartHeight = walletHeight.get();
double percent = targetHeight == syncStartHeight ? 1.0 : ((double) Math.max(1, walletHeight.get() - syncStartHeight) / (double) (targetHeight - syncStartHeight)) * 100d; // grant at least 1 block to show progress
downloadListener.progress(percent, blocksLeft, null);
}
private MoneroWalletRpc createWalletRpc(MoneroWalletConfig config, Integer port) {
// must be connected to daemon

View file

@ -268,8 +268,10 @@ mainView.footer.localhostMoneroNode=(localhost)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Fee rate: {0} sat/vB
mainView.footer.xmrInfo.initializing=Connecting to Monero network
mainView.footer.xmrInfo.synchronizingWith=Synchronizing with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Synced with {0} at block {1}
mainView.footer.xmrInfo.synchronizingDaemonWith=Synchronizing daemon with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedDaemonWith=Daemon synchronized with {0} at block {1}
mainView.footer.xmrInfo.synchronizingWalletWith=Synchronizing wallet with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedWalletWith=Wallet synchronized with {0} at block {1}
mainView.footer.xmrInfo.connectingTo=Connecting to
mainView.footer.xmrInfo.connectionFailed=Connection failed to
mainView.footer.xmrPeers=Monero network peers: {0}

View file

@ -249,8 +249,8 @@ mainView.footer.localhostMoneroNode=(localhost)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Aktuální poplatek: {0} sat/vB
mainView.footer.xmrInfo.initializing=Připojování do Moneroové sítě
mainView.footer.xmrInfo.synchronizingWith=Synchronizace s {0} v bloku: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Synchronizováno s {0} v bloku {1}
mainView.footer.xmrInfo.synchronizingDaemonWith=Synchronizace s {0} v bloku: {1} / {2}
mainView.footer.xmrInfo.synchronizedDaemonWith=Synchronizováno s {0} v bloku {1}
mainView.footer.xmrInfo.connectingTo=Připojování
mainView.footer.xmrInfo.connectionFailed=Připojení se nezdařilo
mainView.footer.xmrPeers=Monero síťové nody: {0}

View file

@ -249,8 +249,8 @@ mainView.footer.localhostMoneroNode=(localhost)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Aktuelle Gebühr: {0} sat/vB
mainView.footer.xmrInfo.initializing=Verbindung mit Monero-Netzwerk wird hergestellt
mainView.footer.xmrInfo.synchronizingWith=Synchronisierung mit {0} bei Block: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Synchronisierung mit {0} bei Block {1}
mainView.footer.xmrInfo.synchronizingDaemonWith=Synchronisierung mit {0} bei Block: {1} / {2}
mainView.footer.xmrInfo.synchronizedDaemonWith=Synchronisierung mit {0} bei Block {1}
mainView.footer.xmrInfo.connectingTo=Verbinde mit
mainView.footer.xmrInfo.connectionFailed=Verbindung fehlgeschlagen zu
mainView.footer.xmrPeers=Monero Netzwerk Peers: {0}

View file

@ -249,8 +249,8 @@ mainView.footer.localhostMoneroNode=(localhost)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/Tasas actuales: {0} sat/vB
mainView.footer.xmrInfo.initializing=Conectando a la red Monero
mainView.footer.xmrInfo.synchronizingWith=Sincronizando con {0} en el bloque: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Sincronizado con {0} en el bloque {1}
mainView.footer.xmrInfo.synchronizingDaemonWith=Sincronizando con {0} en el bloque: {1} / {2}
mainView.footer.xmrInfo.synchronizedDaemonWith=Sincronizado con {0} en el bloque {1}
mainView.footer.xmrInfo.connectingTo=Conectando a
mainView.footer.xmrInfo.connectionFailed=Conexión fallida a
mainView.footer.xmrPeers=Pares de Monero: {0}

View file

@ -249,8 +249,8 @@ mainView.footer.localhostMoneroNode=(لوکال هاست)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Fee rate: {0} sat/vB
mainView.footer.xmrInfo.initializing=در حال ارتباط با شبکه بیت‌کوین
mainView.footer.xmrInfo.synchronizingWith=Synchronizing with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Synced with {0} at block {1}
mainView.footer.xmrInfo.synchronizingDaemonWith=Synchronizing with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedDaemonWith=Synced with {0} at block {1}
mainView.footer.xmrInfo.connectingTo=در حال ایجاد ارتباط با
mainView.footer.xmrInfo.connectionFailed=Connection failed to
mainView.footer.xmrPeers=Monero network peers: {0}

View file

@ -249,8 +249,8 @@ mainView.footer.localhostMoneroNode=(localhost)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Taux des frais: {0} sat/vB
mainView.footer.xmrInfo.initializing=Connexion au réseau Monero en cours
mainView.footer.xmrInfo.synchronizingWith=Synchronisation avec {0} au block: {1}/ {2}
mainView.footer.xmrInfo.synchronizedWith=Synchronisé avec {0} au block {1}
mainView.footer.xmrInfo.synchronizingDaemonWith=Synchronisation avec {0} au block: {1}/ {2}
mainView.footer.xmrInfo.synchronizedDaemonWith=Synchronisé avec {0} au block {1}
mainView.footer.xmrInfo.connectingTo=Se connecte à
mainView.footer.xmrInfo.connectionFailed=Échec de la connexion à
mainView.footer.xmrPeers=Pairs du réseau Monero: {0}

View file

@ -249,8 +249,6 @@ mainView.footer.localhostMoneroNode=(localhost)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Fee rate: {0} sat/vB
mainView.footer.xmrInfo.initializing=Connessione alla rete Monero
mainView.footer.xmrInfo.synchronizingWith=Synchronizing with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Synced with {0} at block {1}
mainView.footer.xmrInfo.connectingTo=Connessione a
mainView.footer.xmrInfo.connectionFailed=Connessione fallita
mainView.footer.xmrPeers=Monero network peers: {0}

View file

@ -249,8 +249,8 @@ mainView.footer.localhostMoneroNode=(ローカルホスト)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ 手数料率: {0} サトシ/vB
mainView.footer.xmrInfo.initializing=ビットコインネットワークに接続中
mainView.footer.xmrInfo.synchronizingWith={0}と同期中、ブロック: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith={0}と同期されています、ブロック{1}に
mainView.footer.xmrInfo.synchronizingDaemonWith={0}と同期中、ブロック: {1} / {2}
mainView.footer.xmrInfo.synchronizedDaemonWith={0}と同期されています、ブロック{1}に
mainView.footer.xmrInfo.connectingTo=接続中:
mainView.footer.xmrInfo.connectionFailed=接続失敗
mainView.footer.xmrPeers=Moneroネットワークピア: {0}

View file

@ -252,8 +252,6 @@ mainView.footer.localhostMoneroNode=(localhost)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Fee rate: {0} sat/vB
mainView.footer.xmrInfo.initializing=Conectando-se à rede Monero
mainView.footer.xmrInfo.synchronizingWith=Synchronizing with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Synced with {0} at block {1}
mainView.footer.xmrInfo.connectingTo=Conectando-se a
mainView.footer.xmrInfo.connectionFailed=Falha na conexão à
mainView.footer.xmrPeers=Monero network peers: {0}

View file

@ -249,8 +249,6 @@ mainView.footer.localhostMoneroNode=(localhost)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Fee rate: {0} sat/vB
mainView.footer.xmrInfo.initializing=Conectando à rede Monero
mainView.footer.xmrInfo.synchronizingWith=Synchronizing with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Synced with {0} at block {1}
mainView.footer.xmrInfo.connectingTo=Conectando à
mainView.footer.xmrInfo.connectionFailed=Connection failed to
mainView.footer.xmrPeers=Monero network peers: {0}

View file

@ -249,8 +249,6 @@ mainView.footer.localhostMoneroNode=(локальный узел)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Fee rate: {0} sat/vB
mainView.footer.xmrInfo.initializing=Подключение к сети Биткойн
mainView.footer.xmrInfo.synchronizingWith=Synchronizing with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Synced with {0} at block {1}
mainView.footer.xmrInfo.connectingTo=Подключение к
mainView.footer.xmrInfo.connectionFailed=Connection failed to
mainView.footer.xmrPeers=Monero network peers: {0}

View file

@ -249,8 +249,6 @@ mainView.footer.localhostMoneroNode=(แม่ข่ายเฉพาะที
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Fee rate: {0} sat/vB
mainView.footer.xmrInfo.initializing=Connecting to Monero network
mainView.footer.xmrInfo.synchronizingWith=Synchronizing with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Synced with {0} at block {1}
mainView.footer.xmrInfo.connectingTo=Connecting to
mainView.footer.xmrInfo.connectionFailed=Connection failed to
mainView.footer.xmrPeers=Monero network peers: {0}

View file

@ -249,8 +249,6 @@ mainView.footer.localhostMoneroNode=(Máy chủ nội bộ)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Fee rate: {0} sat/vB
mainView.footer.xmrInfo.initializing=Đang kết nối với mạng Monero
mainView.footer.xmrInfo.synchronizingWith=Synchronizing with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Synced with {0} at block {1}
mainView.footer.xmrInfo.connectingTo=Đang kết nối với
mainView.footer.xmrInfo.connectionFailed=Connection failed to
mainView.footer.xmrPeers=Monero network peers: {0}

View file

@ -249,8 +249,8 @@ mainView.footer.localhostMoneroNode=(本地主机)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ 矿工手费率:{0} 聪/字节
mainView.footer.xmrInfo.initializing=连接至比特币网络
mainView.footer.xmrInfo.synchronizingWith=正在通过{0}同步区块:{1}/{2}
mainView.footer.xmrInfo.synchronizedWith=已通过{0}同步至区块{1}
mainView.footer.xmrInfo.synchronizingDaemonWith=正在通过{0}同步区块:{1}/{2}
mainView.footer.xmrInfo.synchronizedDaemonWith=已通过{0}同步至区块{1}
mainView.footer.xmrInfo.connectingTo=连接至
mainView.footer.xmrInfo.connectionFailed=连接失败:
mainView.footer.xmrPeers=Monero网络节点{0}

View file

@ -249,8 +249,6 @@ mainView.footer.localhostMoneroNode=(本地主機)
mainView.footer.xmrInfo={0} {1}
mainView.footer.xmrFeeRate=/ Fee rate: {0} sat/vB
mainView.footer.xmrInfo.initializing=連接至比特幣網絡
mainView.footer.xmrInfo.synchronizingWith=Synchronizing with {0} at block: {1} / {2}
mainView.footer.xmrInfo.synchronizedWith=Synced with {0} at block {1}
mainView.footer.xmrInfo.connectingTo=連接至
mainView.footer.xmrInfo.connectionFailed=連接失敗:
mainView.footer.xmrPeers=Monero網絡節點{0}

View file

@ -423,6 +423,7 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
.show());
havenoSetup.getXmrDaemonSyncProgress().addListener((observable, oldValue, newValue) -> updateXmrDaemonSyncProgress());
havenoSetup.getXmrWalletSyncProgress().addListener((observable, oldValue, newValue) -> updateXmrWalletSyncProgress());
havenoSetup.setFilterWarningHandler(warning -> new Popup().warning(warning).show());
@ -539,6 +540,11 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
final DoubleProperty xmrDaemonSyncProgress = havenoSetup.getXmrDaemonSyncProgress();
combinedSyncProgress.set(xmrDaemonSyncProgress.doubleValue());
}
private void updateXmrWalletSyncProgress() {
final DoubleProperty xmrWalletSyncProgress = havenoSetup.getXmrWalletSyncProgress();
combinedSyncProgress.set(xmrWalletSyncProgress.doubleValue());
}
private void setupInvalidOpenOffersHandler() {
openOfferManager.getInvalidOffers().addListener((ListChangeListener<Tuple2<OpenOffer, String>>) c -> {