aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/walletdb.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2022-04-12 11:35:22 -0400
committerAndrew Chow <github@achow101.com>2023-06-08 05:43:21 -0400
commit01b35b55a119dc7ac915fc621ecebcd5c50ccb55 (patch)
tree9391a855b4f364e21d9dcfd4fc678ee3ef03adae /src/wallet/walletdb.cpp
parenta36134fcc7b40671d538931f621c8c15ffacc3d2 (diff)
downloadbitcoin-01b35b55a119dc7ac915fc621ecebcd5c50ccb55.tar.xz
walletdb: Refactor minversion loading
Move minversion loading to its own function in WalletBatch
Diffstat (limited to 'src/wallet/walletdb.cpp')
-rw-r--r--src/wallet/walletdb.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index 34fe8ab17f..96ded3d876 100644
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -791,6 +791,18 @@ bool WalletBatch::IsKeyType(const std::string& strType)
strType == DBKeys::MASTER_KEY || strType == DBKeys::CRYPTED_KEY);
}
+static DBErrors LoadMinVersion(CWallet* pwallet, DatabaseBatch& batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
+{
+ AssertLockHeld(pwallet->cs_wallet);
+ int nMinVersion = 0;
+ if (batch.Read(DBKeys::MINVERSION, nMinVersion)) {
+ if (nMinVersion > FEATURE_LATEST)
+ return DBErrors::TOO_NEW;
+ pwallet->LoadMinVersion(nMinVersion);
+ }
+ return DBErrors::LOAD_OK;
+}
+
DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
{
CWalletScanState wss;
@@ -806,12 +818,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
pwallet->WalletLogPrintf("Wallet file version = %d, last client version = %d\n", pwallet->GetVersion(), last_client);
try {
- int nMinVersion = 0;
- if (m_batch->Read(DBKeys::MINVERSION, nMinVersion)) {
- if (nMinVersion > FEATURE_LATEST)
- return DBErrors::TOO_NEW;
- pwallet->LoadMinVersion(nMinVersion);
- }
+ if ((result = LoadMinVersion(pwallet, *m_batch)) != DBErrors::LOAD_OK) return result;
// Load wallet flags, so they are known when processing other records.
// The FLAGS key is absent during wallet creation.