mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-07 19:22:17 +01:00
scripted-diff: Rename wallet database classes
-BEGIN VERIFY SCRIPT-
sed -i 's/\<CWalletDBWrapper\>/BerkeleyDatabase/g' src/wallet/db.h src/wallet/db.cpp
sed -i '/statuses/i/** Backend-agnostic database type. */\nusing WalletDatabase = BerkeleyDatabase\;\n' src/wallet/walletdb.h
ren() { git grep -l "\<$1\>" 'src/*.cpp' 'src/*.h' ':(exclude)*dbwrapper*' test | xargs sed -i "s:\<$1\>:$2:g"; }
ren CDBEnv BerkeleyEnvironment
ren CDB BerkeleyBatch
ren CWalletDBWrapper WalletDatabase
ren CWalletDB WalletBatch
ren dbw database
ren m_dbw m_database
ren walletdb batch
ren pwalletdb batch
ren pwalletdbIn batch_in
ren wallet/batch.h wallet/walletdb.h
ren pwalletdbEncryption encrypted_batch
-END VERIFY SCRIPT-
This commit is contained in:
@@ -21,42 +21,42 @@
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
//
|
||||
// CWalletDB
|
||||
// WalletBatch
|
||||
//
|
||||
|
||||
bool CWalletDB::WriteName(const std::string& strAddress, const std::string& strName)
|
||||
bool WalletBatch::WriteName(const std::string& strAddress, const std::string& strName)
|
||||
{
|
||||
return WriteIC(std::make_pair(std::string("name"), strAddress), strName);
|
||||
}
|
||||
|
||||
bool CWalletDB::EraseName(const std::string& strAddress)
|
||||
bool WalletBatch::EraseName(const std::string& strAddress)
|
||||
{
|
||||
// This should only be used for sending addresses, never for receiving addresses,
|
||||
// receiving addresses must always have an address book entry if they're not change return.
|
||||
return EraseIC(std::make_pair(std::string("name"), strAddress));
|
||||
}
|
||||
|
||||
bool CWalletDB::WritePurpose(const std::string& strAddress, const std::string& strPurpose)
|
||||
bool WalletBatch::WritePurpose(const std::string& strAddress, const std::string& strPurpose)
|
||||
{
|
||||
return WriteIC(std::make_pair(std::string("purpose"), strAddress), strPurpose);
|
||||
}
|
||||
|
||||
bool CWalletDB::ErasePurpose(const std::string& strAddress)
|
||||
bool WalletBatch::ErasePurpose(const std::string& strAddress)
|
||||
{
|
||||
return EraseIC(std::make_pair(std::string("purpose"), strAddress));
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteTx(const CWalletTx& wtx)
|
||||
bool WalletBatch::WriteTx(const CWalletTx& wtx)
|
||||
{
|
||||
return WriteIC(std::make_pair(std::string("tx"), wtx.GetHash()), wtx);
|
||||
}
|
||||
|
||||
bool CWalletDB::EraseTx(uint256 hash)
|
||||
bool WalletBatch::EraseTx(uint256 hash)
|
||||
{
|
||||
return EraseIC(std::make_pair(std::string("tx"), hash));
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey, const CKeyMetadata& keyMeta)
|
||||
bool WalletBatch::WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey, const CKeyMetadata& keyMeta)
|
||||
{
|
||||
if (!WriteIC(std::make_pair(std::string("keymeta"), vchPubKey), keyMeta, false)) {
|
||||
return false;
|
||||
@@ -71,7 +71,7 @@ bool CWalletDB::WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey, c
|
||||
return WriteIC(std::make_pair(std::string("key"), vchPubKey), std::make_pair(vchPrivKey, Hash(vchKey.begin(), vchKey.end())), false);
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteCryptedKey(const CPubKey& vchPubKey,
|
||||
bool WalletBatch::WriteCryptedKey(const CPubKey& vchPubKey,
|
||||
const std::vector<unsigned char>& vchCryptedSecret,
|
||||
const CKeyMetadata &keyMeta)
|
||||
{
|
||||
@@ -87,17 +87,17 @@ bool CWalletDB::WriteCryptedKey(const CPubKey& vchPubKey,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey)
|
||||
bool WalletBatch::WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey)
|
||||
{
|
||||
return WriteIC(std::make_pair(std::string("mkey"), nID), kMasterKey, true);
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteCScript(const uint160& hash, const CScript& redeemScript)
|
||||
bool WalletBatch::WriteCScript(const uint160& hash, const CScript& redeemScript)
|
||||
{
|
||||
return WriteIC(std::make_pair(std::string("cscript"), hash), redeemScript, false);
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteWatchOnly(const CScript &dest, const CKeyMetadata& keyMeta)
|
||||
bool WalletBatch::WriteWatchOnly(const CScript &dest, const CKeyMetadata& keyMeta)
|
||||
{
|
||||
if (!WriteIC(std::make_pair(std::string("watchmeta"), dest), keyMeta)) {
|
||||
return false;
|
||||
@@ -105,7 +105,7 @@ bool CWalletDB::WriteWatchOnly(const CScript &dest, const CKeyMetadata& keyMeta)
|
||||
return WriteIC(std::make_pair(std::string("watchs"), dest), '1');
|
||||
}
|
||||
|
||||
bool CWalletDB::EraseWatchOnly(const CScript &dest)
|
||||
bool WalletBatch::EraseWatchOnly(const CScript &dest)
|
||||
{
|
||||
if (!EraseIC(std::make_pair(std::string("watchmeta"), dest))) {
|
||||
return false;
|
||||
@@ -113,60 +113,60 @@ bool CWalletDB::EraseWatchOnly(const CScript &dest)
|
||||
return EraseIC(std::make_pair(std::string("watchs"), dest));
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteBestBlock(const CBlockLocator& locator)
|
||||
bool WalletBatch::WriteBestBlock(const CBlockLocator& locator)
|
||||
{
|
||||
WriteIC(std::string("bestblock"), CBlockLocator()); // Write empty block locator so versions that require a merkle branch automatically rescan
|
||||
return WriteIC(std::string("bestblock_nomerkle"), locator);
|
||||
}
|
||||
|
||||
bool CWalletDB::ReadBestBlock(CBlockLocator& locator)
|
||||
bool WalletBatch::ReadBestBlock(CBlockLocator& locator)
|
||||
{
|
||||
if (batch.Read(std::string("bestblock"), locator) && !locator.vHave.empty()) return true;
|
||||
return batch.Read(std::string("bestblock_nomerkle"), locator);
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteOrderPosNext(int64_t nOrderPosNext)
|
||||
bool WalletBatch::WriteOrderPosNext(int64_t nOrderPosNext)
|
||||
{
|
||||
return WriteIC(std::string("orderposnext"), nOrderPosNext);
|
||||
}
|
||||
|
||||
bool CWalletDB::ReadPool(int64_t nPool, CKeyPool& keypool)
|
||||
bool WalletBatch::ReadPool(int64_t nPool, CKeyPool& keypool)
|
||||
{
|
||||
return batch.Read(std::make_pair(std::string("pool"), nPool), keypool);
|
||||
}
|
||||
|
||||
bool CWalletDB::WritePool(int64_t nPool, const CKeyPool& keypool)
|
||||
bool WalletBatch::WritePool(int64_t nPool, const CKeyPool& keypool)
|
||||
{
|
||||
return WriteIC(std::make_pair(std::string("pool"), nPool), keypool);
|
||||
}
|
||||
|
||||
bool CWalletDB::ErasePool(int64_t nPool)
|
||||
bool WalletBatch::ErasePool(int64_t nPool)
|
||||
{
|
||||
return EraseIC(std::make_pair(std::string("pool"), nPool));
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteMinVersion(int nVersion)
|
||||
bool WalletBatch::WriteMinVersion(int nVersion)
|
||||
{
|
||||
return WriteIC(std::string("minversion"), nVersion);
|
||||
}
|
||||
|
||||
bool CWalletDB::ReadAccount(const std::string& strAccount, CAccount& account)
|
||||
bool WalletBatch::ReadAccount(const std::string& strAccount, CAccount& account)
|
||||
{
|
||||
account.SetNull();
|
||||
return batch.Read(std::make_pair(std::string("acc"), strAccount), account);
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteAccount(const std::string& strAccount, const CAccount& account)
|
||||
bool WalletBatch::WriteAccount(const std::string& strAccount, const CAccount& account)
|
||||
{
|
||||
return WriteIC(std::make_pair(std::string("acc"), strAccount), account);
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry)
|
||||
bool WalletBatch::WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry)
|
||||
{
|
||||
return WriteIC(std::make_pair(std::string("acentry"), std::make_pair(acentry.strAccount, nAccEntryNum)), acentry);
|
||||
}
|
||||
|
||||
CAmount CWalletDB::GetAccountCreditDebit(const std::string& strAccount)
|
||||
CAmount WalletBatch::GetAccountCreditDebit(const std::string& strAccount)
|
||||
{
|
||||
std::list<CAccountingEntry> entries;
|
||||
ListAccountCreditDebit(strAccount, entries);
|
||||
@@ -178,7 +178,7 @@ CAmount CWalletDB::GetAccountCreditDebit(const std::string& strAccount)
|
||||
return nCreditDebit;
|
||||
}
|
||||
|
||||
void CWalletDB::ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& entries)
|
||||
void WalletBatch::ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& entries)
|
||||
{
|
||||
bool fAllAccounts = (strAccount == "*");
|
||||
|
||||
@@ -512,13 +512,13 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWalletDB::IsKeyType(const std::string& strType)
|
||||
bool WalletBatch::IsKeyType(const std::string& strType)
|
||||
{
|
||||
return (strType== "key" || strType == "wkey" ||
|
||||
strType == "mkey" || strType == "ckey");
|
||||
}
|
||||
|
||||
DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
||||
{
|
||||
CWalletScanState wss;
|
||||
bool fNoncriticalErrors = false;
|
||||
@@ -624,7 +624,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
return result;
|
||||
}
|
||||
|
||||
DBErrors CWalletDB::FindWalletTx(std::vector<uint256>& vTxHash, std::vector<CWalletTx>& vWtx)
|
||||
DBErrors WalletBatch::FindWalletTx(std::vector<uint256>& vTxHash, std::vector<CWalletTx>& vWtx)
|
||||
{
|
||||
DBErrors result = DBErrors::LOAD_OK;
|
||||
|
||||
@@ -683,7 +683,7 @@ DBErrors CWalletDB::FindWalletTx(std::vector<uint256>& vTxHash, std::vector<CWal
|
||||
return result;
|
||||
}
|
||||
|
||||
DBErrors CWalletDB::ZapSelectTx(std::vector<uint256>& vTxHashIn, std::vector<uint256>& vTxHashOut)
|
||||
DBErrors WalletBatch::ZapSelectTx(std::vector<uint256>& vTxHashIn, std::vector<uint256>& vTxHashOut)
|
||||
{
|
||||
// build list of wallet TXs and hashes
|
||||
std::vector<uint256> vTxHash;
|
||||
@@ -721,7 +721,7 @@ DBErrors CWalletDB::ZapSelectTx(std::vector<uint256>& vTxHashIn, std::vector<uin
|
||||
return DBErrors::LOAD_OK;
|
||||
}
|
||||
|
||||
DBErrors CWalletDB::ZapWalletTx(std::vector<CWalletTx>& vWtx)
|
||||
DBErrors WalletBatch::ZapWalletTx(std::vector<CWalletTx>& vWtx)
|
||||
{
|
||||
// build list of wallet TXs
|
||||
std::vector<uint256> vTxHash;
|
||||
@@ -749,7 +749,7 @@ void MaybeCompactWalletDB()
|
||||
}
|
||||
|
||||
for (CWalletRef pwallet : vpwallets) {
|
||||
CWalletDBWrapper& dbh = pwallet->GetDBHandle();
|
||||
WalletDatabase& dbh = pwallet->GetDBHandle();
|
||||
|
||||
unsigned int nUpdateCounter = dbh.nUpdateCounter;
|
||||
|
||||
@@ -759,7 +759,7 @@ void MaybeCompactWalletDB()
|
||||
}
|
||||
|
||||
if (dbh.nLastFlushed != nUpdateCounter && GetTime() - dbh.nLastWalletUpdate >= 2) {
|
||||
if (CDB::PeriodicFlush(dbh)) {
|
||||
if (BerkeleyBatch::PeriodicFlush(dbh)) {
|
||||
dbh.nLastFlushed = nUpdateCounter;
|
||||
}
|
||||
}
|
||||
@@ -771,19 +771,19 @@ void MaybeCompactWalletDB()
|
||||
//
|
||||
// Try to (very carefully!) recover wallet file if there is a problem.
|
||||
//
|
||||
bool CWalletDB::Recover(const fs::path& wallet_path, void *callbackDataIn, bool (*recoverKVcallback)(void* callbackData, CDataStream ssKey, CDataStream ssValue), std::string& out_backup_filename)
|
||||
bool WalletBatch::Recover(const fs::path& wallet_path, void *callbackDataIn, bool (*recoverKVcallback)(void* callbackData, CDataStream ssKey, CDataStream ssValue), std::string& out_backup_filename)
|
||||
{
|
||||
return CDB::Recover(wallet_path, callbackDataIn, recoverKVcallback, out_backup_filename);
|
||||
return BerkeleyBatch::Recover(wallet_path, callbackDataIn, recoverKVcallback, out_backup_filename);
|
||||
}
|
||||
|
||||
bool CWalletDB::Recover(const fs::path& wallet_path, std::string& out_backup_filename)
|
||||
bool WalletBatch::Recover(const fs::path& wallet_path, std::string& out_backup_filename)
|
||||
{
|
||||
// recover without a key filter callback
|
||||
// results in recovering all record types
|
||||
return CWalletDB::Recover(wallet_path, nullptr, nullptr, out_backup_filename);
|
||||
return WalletBatch::Recover(wallet_path, nullptr, nullptr, out_backup_filename);
|
||||
}
|
||||
|
||||
bool CWalletDB::RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDataStream ssValue)
|
||||
bool WalletBatch::RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDataStream ssValue)
|
||||
{
|
||||
CWallet *dummyWallet = reinterpret_cast<CWallet*>(callbackData);
|
||||
CWalletScanState dummyWss;
|
||||
@@ -799,60 +799,60 @@ bool CWalletDB::RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDa
|
||||
return false;
|
||||
if (!fReadOK)
|
||||
{
|
||||
LogPrintf("WARNING: CWalletDB::Recover skipping %s: %s\n", strType, strErr);
|
||||
LogPrintf("WARNING: WalletBatch::Recover skipping %s: %s\n", strType, strErr);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWalletDB::VerifyEnvironment(const fs::path& wallet_path, std::string& errorStr)
|
||||
bool WalletBatch::VerifyEnvironment(const fs::path& wallet_path, std::string& errorStr)
|
||||
{
|
||||
return CDB::VerifyEnvironment(wallet_path, errorStr);
|
||||
return BerkeleyBatch::VerifyEnvironment(wallet_path, errorStr);
|
||||
}
|
||||
|
||||
bool CWalletDB::VerifyDatabaseFile(const fs::path& wallet_path, std::string& warningStr, std::string& errorStr)
|
||||
bool WalletBatch::VerifyDatabaseFile(const fs::path& wallet_path, std::string& warningStr, std::string& errorStr)
|
||||
{
|
||||
return CDB::VerifyDatabaseFile(wallet_path, warningStr, errorStr, CWalletDB::Recover);
|
||||
return BerkeleyBatch::VerifyDatabaseFile(wallet_path, warningStr, errorStr, WalletBatch::Recover);
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteDestData(const std::string &address, const std::string &key, const std::string &value)
|
||||
bool WalletBatch::WriteDestData(const std::string &address, const std::string &key, const std::string &value)
|
||||
{
|
||||
return WriteIC(std::make_pair(std::string("destdata"), std::make_pair(address, key)), value);
|
||||
}
|
||||
|
||||
bool CWalletDB::EraseDestData(const std::string &address, const std::string &key)
|
||||
bool WalletBatch::EraseDestData(const std::string &address, const std::string &key)
|
||||
{
|
||||
return EraseIC(std::make_pair(std::string("destdata"), std::make_pair(address, key)));
|
||||
}
|
||||
|
||||
|
||||
bool CWalletDB::WriteHDChain(const CHDChain& chain)
|
||||
bool WalletBatch::WriteHDChain(const CHDChain& chain)
|
||||
{
|
||||
return WriteIC(std::string("hdchain"), chain);
|
||||
}
|
||||
|
||||
bool CWalletDB::TxnBegin()
|
||||
bool WalletBatch::TxnBegin()
|
||||
{
|
||||
return batch.TxnBegin();
|
||||
}
|
||||
|
||||
bool CWalletDB::TxnCommit()
|
||||
bool WalletBatch::TxnCommit()
|
||||
{
|
||||
return batch.TxnCommit();
|
||||
}
|
||||
|
||||
bool CWalletDB::TxnAbort()
|
||||
bool WalletBatch::TxnAbort()
|
||||
{
|
||||
return batch.TxnAbort();
|
||||
}
|
||||
|
||||
bool CWalletDB::ReadVersion(int& nVersion)
|
||||
bool WalletBatch::ReadVersion(int& nVersion)
|
||||
{
|
||||
return batch.ReadVersion(nVersion);
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteVersion(int nVersion)
|
||||
bool WalletBatch::WriteVersion(int nVersion)
|
||||
{
|
||||
return batch.WriteVersion(nVersion);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user