Merge pull request #1315

9150a16 Wallet API: use stored refresh height when rebuilding cache (Jacob Brydolf)
This commit is contained in:
Riccardo Spagni 2016-11-11 12:35:47 +02:00
commit a3cd7230f8
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
2 changed files with 13 additions and 2 deletions

View file

@ -201,6 +201,7 @@ WalletImpl::WalletImpl(bool testnet)
, m_wallet2Callback(nullptr) , m_wallet2Callback(nullptr)
, m_recoveringFromSeed(false) , m_recoveringFromSeed(false)
, m_synchronized(false) , m_synchronized(false)
, m_rebuildWalletCache(false)
{ {
m_wallet = new tools::wallet2(testnet); m_wallet = new tools::wallet2(testnet);
m_history = new TransactionHistoryImpl(this); m_history = new TransactionHistoryImpl(this);
@ -269,6 +270,14 @@ bool WalletImpl::open(const std::string &path, const std::string &password)
m_recoveringFromSeed = false; m_recoveringFromSeed = false;
try { try {
// TODO: handle "deprecated" // 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_wallet->load(path, password);
m_password = password; m_password = password;
@ -998,8 +1007,9 @@ bool WalletImpl::isNewWallet() const
{ {
// in case wallet created without daemon connection, closed and opened again, // 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" // 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) // with the daemon (pull hashes instead of pull blocks).
return !(blockChainHeight() > 1 || m_recoveringFromSeed); // 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) void WalletImpl::doInit(const string &daemon_address, uint64_t upper_transaction_size_limit)

View file

@ -145,6 +145,7 @@ private:
// instead of pulling hashes (fast-refresh) // instead of pulling hashes (fast-refresh)
bool m_recoveringFromSeed; bool m_recoveringFromSeed;
std::atomic<bool> m_synchronized; std::atomic<bool> m_synchronized;
bool m_rebuildWalletCache;
}; };