mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +00:00
cormorant: syncing and pruning improvements
This commit is contained in:
parent
064708f088
commit
41dabac75b
3 changed files with 24 additions and 3 deletions
|
@ -33,6 +33,8 @@ public class Cormorant {
|
||||||
bitcoindClient.importWallets(AppServices.get().getOpenWallets().keySet());
|
bitcoindClient.importWallets(AppServices.get().getOpenWallets().keySet());
|
||||||
} catch(ImportFailedException e) {
|
} catch(ImportFailedException e) {
|
||||||
log.debug("Failed to import wallets", e);
|
log.debug("Failed to import wallets", e);
|
||||||
|
} finally {
|
||||||
|
bitcoindClient.signalInitialImportStarted();
|
||||||
}
|
}
|
||||||
}, "Cormorant Initial Wallet Importer");
|
}, "Cormorant Initial Wallet Importer");
|
||||||
importThread.setDaemon(true);
|
importThread.setDaemon(true);
|
||||||
|
|
|
@ -56,6 +56,8 @@ public class BitcoindClient {
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
private boolean stopped;
|
private boolean stopped;
|
||||||
|
|
||||||
|
private Exception lastPollException;
|
||||||
|
|
||||||
private boolean pruned;
|
private boolean pruned;
|
||||||
private boolean prunedWarningShown = false;
|
private boolean prunedWarningShown = false;
|
||||||
private boolean legacyWalletExists;
|
private boolean legacyWalletExists;
|
||||||
|
@ -101,8 +103,15 @@ public class BitcoindClient {
|
||||||
try {
|
try {
|
||||||
syncing = true;
|
syncing = true;
|
||||||
syncingCondition.await();
|
syncingCondition.await();
|
||||||
|
|
||||||
|
if(syncing) {
|
||||||
|
if(lastPollException instanceof RuntimeException runtimeException) {
|
||||||
|
throw runtimeException;
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Error while waiting for sync to complete", lastPollException);
|
||||||
|
}
|
||||||
} catch(InterruptedException e) {
|
} catch(InterruptedException e) {
|
||||||
throw new CormorantBitcoindException("Interrupted while waiting for sync to complete");
|
throw new RuntimeException("Interrupted while waiting for sync to complete");
|
||||||
} finally {
|
} finally {
|
||||||
syncingLock.unlock();
|
syncingLock.unlock();
|
||||||
}
|
}
|
||||||
|
@ -456,7 +465,7 @@ public class BitcoindClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void signalInitialImportStarted() {
|
public void signalInitialImportStarted() {
|
||||||
if(!initialImportStarted) {
|
if(!initialImportStarted) {
|
||||||
initialImportLock.lock();
|
initialImportLock.lock();
|
||||||
try {
|
try {
|
||||||
|
@ -542,7 +551,17 @@ public class BitcoindClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
lastPollException = e;
|
||||||
log.warn("Error polling Bitcoin Core: " + e.getMessage());
|
log.warn("Error polling Bitcoin Core: " + e.getMessage());
|
||||||
|
|
||||||
|
if(syncing) {
|
||||||
|
syncingLock.lock();
|
||||||
|
try {
|
||||||
|
syncingCondition.signal();
|
||||||
|
} finally {
|
||||||
|
syncingLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,6 @@ public record BlockchainInfo(int blocks, int headers, String bestblockhash, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgressPercent() {
|
public int getProgressPercent() {
|
||||||
return (int) Math.round(verificationprogress * 100);
|
return (int) Math.floor(verificationprogress * 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue