refactor: wallet: Factor out WriteVersion() from PopulateWalletFromDB()
Writing the wallet's `CLIENT_VERSION` (which indicates the last version to have touched a wallet) needs to be done on both wallet creation and wallet loading. The next commit removes the `PopulateWalletFromDatabase()` call from wallet creation, but this behavior needs to be preserved, so this commit factors setting `CLIENT_VERSION` out of `PopulateWalletFromDatabase()` so that wallet creation can use it in the next commit.
This commit is contained in:
1 parent
e12ff8aca0
commit
f35acc893f
2 files changed
+4
-1
No files matched your search
@@ -1175,7 +1175,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (!has_last_client || last_client != CLIENT_VERSION) // Update
|
if (!has_last_client || last_client != CLIENT_VERSION) // Update
|
||||||
m_batch->Write(DBKeys::VERSION, CLIENT_VERSION);
|
this->WriteVersion(CLIENT_VERSION);
|
||||||
|
|
||||||
if (any_unordered)
|
if (any_unordered)
|
||||||
result = pwallet->ReorderTransactions();
|
result = pwallet->ReorderTransactions();
|
||||||
|
|||||||
@@ -265,6 +265,9 @@ public:
|
|||||||
|
|
||||||
DBErrors LoadWallet(CWallet* pwallet);
|
DBErrors LoadWallet(CWallet* pwallet);
|
||||||
|
|
||||||
|
//! Write the given client_version.
|
||||||
|
bool WriteVersion(int client_version) { return m_batch->Write(DBKeys::VERSION, CLIENT_VERSION); }
|
||||||
|
|
||||||
//! Delete records of the given types
|
//! Delete records of the given types
|
||||||
bool EraseRecords(const std::unordered_set<std::string>& types);
|
bool EraseRecords(const std::unordered_set<std::string>& types);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user