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) { public void cormorantScanStatus(CormorantScanStatusEvent event) {
serverToggle.setDisable(true); serverToggle.setDisable(true);
if((AppServices.isConnecting() || AppServices.isConnected()) && !event.isCompleted()) { 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)) { if(event.getProgress() > 0 && (statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING)) {
statusBar.setProgress((double)event.getProgress() / 100); statusBar.setProgress((double)event.getProgress() / 100);
} }

View file

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

View file

@ -187,7 +187,7 @@ public class SparrowTextGui extends MultiWindowTextGUI {
@Subscribe @Subscribe
public void cormorantScanStatusEvent(CormorantScanStatusEvent event) { 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 @Subscribe