mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-01 06:52:35 +02:00
walletdb: Refactor minversion loading
Move minversion loading to its own function in WalletBatch
This commit is contained in:
parent
a36134fcc7
commit
01b35b55a1
@ -791,6 +791,18 @@ bool WalletBatch::IsKeyType(const std::string& strType)
|
|||||||
strType == DBKeys::MASTER_KEY || strType == DBKeys::CRYPTED_KEY);
|
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)
|
DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
||||||
{
|
{
|
||||||
CWalletScanState wss;
|
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);
|
pwallet->WalletLogPrintf("Wallet file version = %d, last client version = %d\n", pwallet->GetVersion(), last_client);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int nMinVersion = 0;
|
if ((result = LoadMinVersion(pwallet, *m_batch)) != DBErrors::LOAD_OK) return result;
|
||||||
if (m_batch->Read(DBKeys::MINVERSION, nMinVersion)) {
|
|
||||||
if (nMinVersion > FEATURE_LATEST)
|
|
||||||
return DBErrors::TOO_NEW;
|
|
||||||
pwallet->LoadMinVersion(nMinVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load wallet flags, so they are known when processing other records.
|
// Load wallet flags, so they are known when processing other records.
|
||||||
// The FLAGS key is absent during wallet creation.
|
// The FLAGS key is absent during wallet creation.
|
||||||
|
Loading…
Reference in New Issue
Block a user