Skip to content

Commit 35e60e7

Browse files
committed
Remove ReadVersion and WriteVersion
The "version" record that these functions read and write are not used anywhere in the code except for one place. There is no reason to expose these functions publicly. Furthermore, this avoids potential confusion as developers may mistake these functions for actually reading and writing the wallet version when they do not.
1 parent b3d4f6c commit 35e60e7

File tree

4 files changed

+3
-28
lines changed

4 files changed

+3
-28
lines changed

src/wallet/db.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ BerkeleyBatch::BerkeleyBatch(BerkeleyDatabase& database, const char* pszMode, bo
587587
if (fCreate && !Exists(std::string("version"))) {
588588
bool fTmp = fReadOnly;
589589
fReadOnly = false;
590-
WriteVersion(CLIENT_VERSION);
590+
Write(std::string("version"), CLIENT_VERSION);
591591
fReadOnly = fTmp;
592592
}
593593
}

src/wallet/db.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,17 +396,6 @@ class BerkeleyBatch
396396
return (ret == 0);
397397
}
398398

399-
bool ReadVersion(int& nVersion)
400-
{
401-
nVersion = 0;
402-
return Read(std::string("version"), nVersion);
403-
}
404-
405-
bool WriteVersion(int nVersion)
406-
{
407-
return Write(std::string("version"), nVersion);
408-
}
409-
410399
bool static Rewrite(BerkeleyDatabase& database, const char* pszSkip = nullptr);
411400
};
412401

src/wallet/walletdb.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
507507

508508
// Last client version to open this wallet, was previously the file version number
509509
int last_client = CLIENT_VERSION;
510-
ReadVersion(last_client);
510+
m_batch.Read(std::string("version"), last_client);
511511

512512
int wallet_version = pwallet->GetVersion();
513513
pwallet->WalletLogPrintf("Wallet File Version = %d\n", wallet_version > 0 ? wallet_version : last_client);
@@ -527,7 +527,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
527527
return DBErrors::NEED_REWRITE;
528528

529529
if (last_client < CLIENT_VERSION) // Update
530-
WriteVersion(CLIENT_VERSION);
530+
m_batch.Write(std::string("version"), CLIENT_VERSION);
531531

532532
if (wss.fAnyUnordered)
533533
result = pwallet->ReorderTransactions();
@@ -770,13 +770,3 @@ bool WalletBatch::TxnAbort()
770770
{
771771
return m_batch.TxnAbort();
772772
}
773-
774-
bool WalletBatch::ReadVersion(int& nVersion)
775-
{
776-
return m_batch.ReadVersion(nVersion);
777-
}
778-
779-
bool WalletBatch::WriteVersion(int nVersion)
780-
{
781-
return m_batch.WriteVersion(nVersion);
782-
}

src/wallet/walletdb.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,6 @@ class WalletBatch
241241
bool TxnCommit();
242242
//! Abort current transaction
243243
bool TxnAbort();
244-
//! Read wallet version
245-
bool ReadVersion(int& nVersion);
246-
//! Write wallet version
247-
bool WriteVersion(int nVersion);
248244
private:
249245
BerkeleyBatch m_batch;
250246
WalletDatabase& m_database;

0 commit comments

Comments
 (0)