aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacob Brydolf <jacob@brydolf.net>2016-11-09 18:46:03 +0100
committerJacob Brydolf <jacob@brydolf.net>2016-11-09 18:46:03 +0100
commit9150a16ed1f7225ac61d2c0a915d16e038f47087 (patch)
tree7cdbe2ff441fc7745401014049957cd9d147b617 /src
parentMerge pull request #1312 (diff)
downloadmonero-9150a16ed1f7225ac61d2c0a915d16e038f47087.tar.xz
Wallet API: use stored refresh height when rebuilding cache
Diffstat (limited to 'src')
-rw-r--r--src/wallet/api/wallet.cpp14
-rw-r--r--src/wallet/api/wallet.h1
2 files changed, 13 insertions, 2 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 6c1c1fea2..ed7bc4410 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -201,6 +201,7 @@ WalletImpl::WalletImpl(bool testnet)
, m_wallet2Callback(nullptr)
, m_recoveringFromSeed(false)
, m_synchronized(false)
+ , m_rebuildWalletCache(false)
{
m_wallet = new tools::wallet2(testnet);
m_history = new TransactionHistoryImpl(this);
@@ -269,6 +270,14 @@ bool WalletImpl::open(const std::string &path, const std::string &password)
m_recoveringFromSeed = false;
try {
// TODO: handle "deprecated"
+ // Check if wallet cache exists
+ bool keys_file_exists;
+ bool wallet_file_exists;
+ tools::wallet2::wallet_exists(path, keys_file_exists, wallet_file_exists);
+ if(!wallet_file_exists){
+ // Rebuilding wallet cache, using refresh height from .keys file
+ m_rebuildWalletCache = true;
+ }
m_wallet->load(path, password);
m_password = password;
@@ -990,8 +999,9 @@ bool WalletImpl::isNewWallet() const
{
// in case wallet created without daemon connection, closed and opened again,
// it's the same case as if it created from scratch, i.e. we need "fast sync"
- // with the daemon (pull hashes instead of pull blocks)
- return !(blockChainHeight() > 1 || m_recoveringFromSeed);
+ // with the daemon (pull hashes instead of pull blocks).
+ // If wallet cache is rebuilt, creation height stored in .keys is used.
+ return !(blockChainHeight() > 1 || m_recoveringFromSeed || m_rebuildWalletCache);
}
void WalletImpl::doInit(const string &daemon_address, uint64_t upper_transaction_size_limit)
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index f40551fac..32e94bb97 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -145,6 +145,7 @@ private:
// instead of pulling hashes (fast-refresh)
bool m_recoveringFromSeed;
std::atomic<bool> m_synchronized;
+ bool m_rebuildWalletCache;
};