mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
warm pubkey cache by deriving all public keys on wallet opening
This commit is contained in:
parent
4217de15a3
commit
fc52670b2d
2 changed files with 27 additions and 1 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
|||
Subproject commit cd1e21ebaa167823dc7e515f21b4acd640237025
|
||||
Subproject commit bd01cb87309bcc4a4739b63a6d7548ca1b25910e
|
|
@ -27,6 +27,7 @@ import javafx.beans.property.SimpleBooleanProperty;
|
|||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.concurrent.ScheduledService;
|
||||
import javafx.concurrent.Service;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.concurrent.Worker;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
|
@ -1062,6 +1063,13 @@ public class AppServices {
|
|||
if(Config.get().getServerType() == ServerType.BITCOIN_CORE) {
|
||||
Platform.runLater(() -> restartBwt(event.getWallet()));
|
||||
}
|
||||
|
||||
//Ensure public key cache is warm
|
||||
WalletKeyDerivationService walletKeyDerivationService = new WalletKeyDerivationService(event.getWallet());
|
||||
walletKeyDerivationService.setOnFailed(workerStateEvent -> {
|
||||
log.error("Error deriving public keys", workerStateEvent.getSource().getException());
|
||||
});
|
||||
walletKeyDerivationService.start();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -1101,4 +1109,22 @@ public class AppServices {
|
|||
onlineProperty.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class WalletKeyDerivationService extends Service<Boolean> {
|
||||
private final Wallet wallet;
|
||||
|
||||
public WalletKeyDerivationService(Wallet wallet) {
|
||||
this.wallet = wallet;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Task<Boolean> createTask() {
|
||||
return new Task<>() {
|
||||
protected Boolean call() {
|
||||
wallet.derivePublicKeys();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue