call wallet.sync() on startup after background sync with progress

This commit is contained in:
woodser 2023-12-09 12:34:27 -05:00
parent 74cfd474ad
commit d8ac901d4a

View File

@ -737,9 +737,13 @@ public class XmrWalletService {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
syncWalletWithProgress(); // blocking syncWalletWithProgress(); // blocking
log.info("Done syncing main wallet in " + (System.currentTimeMillis() - time) + " ms"); log.info("Done syncing main wallet in " + (System.currentTimeMillis() - time) + " ms");
wallet.startSyncing(xmrConnectionService.getRefreshPeriodMs());
wallet.getTxs(new MoneroTxQuery().setIsLocked(true)); // TODO: main wallet's balance does update on startup with 0 conf PaymentReceivedMessage until pool txs fetched? // log wallet balances
if (getMoneroNetworkType() != MoneroNetworkType.MAINNET) log.info("Monero wallet balance={}, unlocked balance={}", wallet.getBalance(0), wallet.getUnlockedBalance(0)); if (getMoneroNetworkType() != MoneroNetworkType.MAINNET) {
BigInteger balance = wallet.getBalance();
BigInteger unlockedBalance = wallet.getUnlockedBalance();
log.info("Monero wallet unlocked balance={}, pending balance={}, total balance={}", unlockedBalance, balance.subtract(unlockedBalance), balance);
}
// reapply connection after wallet synced // reapply connection after wallet synced
onConnectionChanged(xmrConnectionService.getConnection()); onConnectionChanged(xmrConnectionService.getConnection());
@ -782,14 +786,15 @@ public class XmrWalletService {
private void syncWalletWithProgress() { private void syncWalletWithProgress() {
updateSyncProgress(); updateSyncProgress();
wallet.startSyncing(); wallet.startSyncing(xmrConnectionService.getRefreshPeriodMs());
CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1);
syncLooper = new TaskLooper(() -> { syncLooper = new TaskLooper(() -> {
if (wallet.getHeight() < xmrConnectionService.getTargetHeight()) updateSyncProgress(); if (wallet.getHeight() < xmrConnectionService.getTargetHeight()) updateSyncProgress();
else { else {
syncLooper.stop();
wallet.sync(); // necessary to fully sync
wasWalletSynced = true; wasWalletSynced = true;
updateSyncProgress(); updateSyncProgress();
syncLooper.stop();
latch.countDown(); latch.countDown();
} }
}); });