cormorant: send first scan event immediately

This commit is contained in:
Craig Raw 2022-12-14 16:29:16 +02:00
parent 5ca60699ef
commit 66dc394215
3 changed files with 7 additions and 4 deletions

View file

@ -2608,7 +2608,7 @@ public class AppController implements Initializable {
public void cormorantScanStatus(CormorantScanStatusEvent event) {
serverToggle.setDisable(true);
if((AppServices.isConnecting() || AppServices.isConnected()) && !event.isCompleted()) {
statusUpdated(new StatusEvent("Scanning... (" + event.getProgress() + "% complete, " + event.getRemainingAsString() + " remaining)"));
statusUpdated(new StatusEvent("Scanning... (" + event.getProgress() + "% complete" + (event.getRemainingAsString().isEmpty() ? ")" : ", " + event.getRemainingAsString() + " remaining)")));
if(event.getProgress() > 0 && (statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING)) {
statusBar.setProgress((double)event.getProgress() / 100);
}

View file

@ -292,12 +292,13 @@ public class BitcoindClient {
scanningLock.lock();
try {
scanningDescriptors.addAll(importingDescriptors.keySet());
Platform.runLater(() -> EventManager.get().post(new CormorantScanStatusEvent("Scanning (0%)", getScanningWallets(), 0, null)));
results = getBitcoindService().importDescriptors(importDescriptors);
} finally {
scanningLock.unlock();
Set<Wallet> scanningWallets = getScanningWallets();
scanningDescriptors.clear();
Platform.runLater(() -> EventManager.get().post(new CormorantScanStatusEvent("Scanning completed", scanningWallets, 100, Duration.ZERO)));
scanningDescriptors.clear();
}
for(int i = 0; i < importDescriptors.size(); i++) {
@ -535,9 +536,11 @@ public class BitcoindClient {
Set<Wallet> scanningWallets = getScanningWallets();
int percent = walletInfo.scanning().getPercent();
Duration remainingDuration = walletInfo.scanning().getRemaining();
if(percent > 0) {
Platform.runLater(() -> EventManager.get().post(new CormorantScanStatusEvent("Scanning" + (percent < 100 ? " (" + percent + "%)" : ""), scanningWallets, percent, remainingDuration)));
}
}
}
} catch(Exception e) {
log.warn("Error polling Bitcoin Core: " + e.getMessage());
}

View file

@ -187,7 +187,7 @@ public class SparrowTextGui extends MultiWindowTextGUI {
@Subscribe
public void cormorantScanStatusEvent(CormorantScanStatusEvent event) {
statusUpdated(new StatusEvent(event.isCompleted() ? "" : "Scanning... (" + event.getProgress() + "% complete, " + event.getRemainingAsString() + " remaining)"));
statusUpdated(new StatusEvent(event.isCompleted() ? "" : "Scanning... (" + event.getProgress() + "% complete" + (event.getRemainingAsString().isEmpty() ? ")" : ", " + event.getRemainingAsString() + " remaining)")));
}
@Subscribe