mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +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());
|
||||
} catch(ImportFailedException e) {
|
||||
log.debug("Failed to import wallets", e);
|
||||
} finally {
|
||||
bitcoindClient.signalInitialImportStarted();
|
||||
}
|
||||
}, "Cormorant Initial Wallet Importer");
|
||||
importThread.setDaemon(true);
|
||||
|
|
|
@ -56,6 +56,8 @@ public class BitcoindClient {
|
|||
private boolean initialized;
|
||||
private boolean stopped;
|
||||
|
||||
private Exception lastPollException;
|
||||
|
||||
private boolean pruned;
|
||||
private boolean prunedWarningShown = false;
|
||||
private boolean legacyWalletExists;
|
||||
|
@ -101,8 +103,15 @@ public class BitcoindClient {
|
|||
try {
|
||||
syncing = true;
|
||||
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) {
|
||||
throw new CormorantBitcoindException("Interrupted while waiting for sync to complete");
|
||||
throw new RuntimeException("Interrupted while waiting for sync to complete");
|
||||
} finally {
|
||||
syncingLock.unlock();
|
||||
}
|
||||
|
@ -456,7 +465,7 @@ public class BitcoindClient {
|
|||
}
|
||||
}
|
||||
|
||||
private void signalInitialImportStarted() {
|
||||
public void signalInitialImportStarted() {
|
||||
if(!initialImportStarted) {
|
||||
initialImportLock.lock();
|
||||
try {
|
||||
|
@ -542,7 +551,17 @@ public class BitcoindClient {
|
|||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
lastPollException = e;
|
||||
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() {
|
||||
return (int) Math.round(verificationprogress * 100);
|
||||
return (int) Math.floor(verificationprogress * 100);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue