mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
wallet: don't read db every time that a new WalletBatch is created
Better to perform the action only one time (during 'LoadWallet'). Where the value is being used.
This commit is contained in:
parent
26ec2f2d6b
commit
bda8ebe608
2 changed files with 3 additions and 11 deletions
|
@ -315,12 +315,6 @@ BerkeleyBatch::BerkeleyBatch(BerkeleyDatabase& database, const bool read_only, b
|
||||||
env = database.env.get();
|
env = database.env.get();
|
||||||
pdb = database.m_db.get();
|
pdb = database.m_db.get();
|
||||||
strFile = fs::PathToString(database.m_filename);
|
strFile = fs::PathToString(database.m_filename);
|
||||||
if (!Exists(std::string("version"))) {
|
|
||||||
bool fTmp = fReadOnly;
|
|
||||||
fReadOnly = false;
|
|
||||||
Write(std::string("version"), CLIENT_VERSION);
|
|
||||||
fReadOnly = fTmp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BerkeleyDatabase::Open()
|
void BerkeleyDatabase::Open()
|
||||||
|
|
|
@ -885,10 +885,8 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
||||||
|
|
||||||
// Last client version to open this wallet, was previously the file version number
|
// Last client version to open this wallet, was previously the file version number
|
||||||
int last_client = CLIENT_VERSION;
|
int last_client = CLIENT_VERSION;
|
||||||
m_batch->Read(DBKeys::VERSION, last_client);
|
bool has_last_client = m_batch->Read(DBKeys::VERSION, last_client);
|
||||||
|
pwallet->WalletLogPrintf("Wallet file version = %d, last client version = %d\n", pwallet->GetVersion(), last_client);
|
||||||
int wallet_version = pwallet->GetVersion();
|
|
||||||
pwallet->WalletLogPrintf("Wallet File Version = %d\n", wallet_version > 0 ? wallet_version : last_client);
|
|
||||||
|
|
||||||
pwallet->WalletLogPrintf("Keys: %u plaintext, %u encrypted, %u w/ metadata, %u total. Unknown wallet records: %u\n",
|
pwallet->WalletLogPrintf("Keys: %u plaintext, %u encrypted, %u w/ metadata, %u total. Unknown wallet records: %u\n",
|
||||||
wss.nKeys, wss.nCKeys, wss.nKeyMeta, wss.nKeys + wss.nCKeys, wss.m_unknown_records);
|
wss.nKeys, wss.nCKeys, wss.nKeyMeta, wss.nKeys + wss.nCKeys, wss.m_unknown_records);
|
||||||
|
@ -909,7 +907,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
||||||
if (wss.fIsEncrypted && (last_client == 40000 || last_client == 50000))
|
if (wss.fIsEncrypted && (last_client == 40000 || last_client == 50000))
|
||||||
return DBErrors::NEED_REWRITE;
|
return DBErrors::NEED_REWRITE;
|
||||||
|
|
||||||
if (last_client < CLIENT_VERSION) // Update
|
if (!has_last_client || last_client < CLIENT_VERSION) // Update
|
||||||
m_batch->Write(DBKeys::VERSION, CLIENT_VERSION);
|
m_batch->Write(DBKeys::VERSION, CLIENT_VERSION);
|
||||||
|
|
||||||
if (wss.fAnyUnordered)
|
if (wss.fAnyUnordered)
|
||||||
|
|
Loading…
Add table
Reference in a new issue