From 7c9d2231cc08f644f4a4150f6cbde7c15f24c102 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Thu, 10 Nov 2016 12:11:25 +0100 Subject: [PATCH 1/2] remove unnecessary i/o --- main.qml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/main.qml b/main.qml index 6f5bdde4..4a787c96 100644 --- a/main.qml +++ b/main.qml @@ -287,13 +287,17 @@ ApplicationWindow { daemonSynced = (currentWallet.connected != Wallet.ConnectionStatus_Disconnected && dCurrentBlock >= dTargetBlock) - - // Store wallet after every refresh. + // Refresh is succesfull if blockchain height > 1 if (currentWallet.blockChainHeight() > 1){ - //TODO: Doesn't need path after creation. Change libwalletqt - currentWallet.store("") - console.log("Saving wallet"); + // Save new wallet after first refresh + // Wallet is nomrmally saved to disk on app exit. This prevents rescan from block 0 after app crash + if(isNewWallet){ + console.log("Saving wallet after first refresh"); + //TODO: Doesn't need path argument after creation. Change libwalletqt + currentWallet.store("") + isNewWallet = false + } // recovering from seed is finished after first refresh if(persistentSettings.is_recovering) { @@ -301,7 +305,6 @@ ApplicationWindow { } } - isNewWallet = false // initialize transaction history once wallet is initializef first time; if (!walletInitialized) { @@ -969,6 +972,7 @@ ApplicationWindow { } } onClosing: { - //walletManager.closeWallet(currentWallet); + // Close and save to disk on app close + walletManager.closeWallet(currentWallet); } } From 4e61ebeedb466710c59c382aa348f54a08cb8bf5 Mon Sep 17 00:00:00 2001 From: Jacob Brydolf Date: Thu, 10 Nov 2016 12:23:43 +0100 Subject: [PATCH 2/2] add default argument to store() --- main.qml | 3 +-- src/libwalletqt/Wallet.h | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.qml b/main.qml index 4a787c96..0d6c9a62 100644 --- a/main.qml +++ b/main.qml @@ -294,8 +294,7 @@ ApplicationWindow { // Wallet is nomrmally saved to disk on app exit. This prevents rescan from block 0 after app crash if(isNewWallet){ console.log("Saving wallet after first refresh"); - //TODO: Doesn't need path argument after creation. Change libwalletqt - currentWallet.store("") + currentWallet.store() isNewWallet = false } diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 458dea90..26e66f6e 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -79,7 +79,8 @@ public: QString address() const; //! saves wallet to the file by given path - Q_INVOKABLE bool store(const QString &path); + //! empty path stores in current location + Q_INVOKABLE bool store(const QString &path = ""); //! initializes wallet Q_INVOKABLE bool init(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering = false, quint64 restoreHeight = 0);