diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -21,8 +21,6 @@ #include #include -using namespace std; - static uint64_t nAccountingEntryNumber = 0; static std::atomic nWalletDBUpdateCounter; @@ -31,28 +29,28 @@ // CWalletDB // -bool CWalletDB::WriteName(const string &strAddress, const string &strName) { +bool CWalletDB::WriteName(const std::string &strAddress, const std::string &strName) { nWalletDBUpdateCounter++; - return Write(make_pair(string("name"), strAddress), strName); + return Write(make_pair(std::string("name"), strAddress), strName); } -bool CWalletDB::EraseName(const string &strAddress) { +bool CWalletDB::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. nWalletDBUpdateCounter++; - return Erase(make_pair(string("name"), strAddress)); + return Erase(make_pair(std::string("name"), strAddress)); } -bool CWalletDB::WritePurpose(const string &strAddress, - const string &strPurpose) { +bool CWalletDB::WritePurpose(const std::string &strAddress, + const std::string &strPurpose) { nWalletDBUpdateCounter++; - return Write(make_pair(string("purpose"), strAddress), strPurpose); + return Write(make_pair(std::string("purpose"), strAddress), strPurpose); } -bool CWalletDB::ErasePurpose(const string &strPurpose) { +bool CWalletDB::ErasePurpose(const std::string &strPurpose) { nWalletDBUpdateCounter++; - return Erase(make_pair(string("purpose"), strPurpose)); + return Erase(make_pair(std::string("purpose"), strPurpose)); } bool CWalletDB::WriteTx(const CWalletTx &wtx) { @@ -178,14 +176,14 @@ return Write(std::string("minversion"), nVersion); } -bool CWalletDB::ReadAccount(const string &strAccount, CAccount &account) { +bool CWalletDB::ReadAccount(const std::string &strAccount, CAccount &account) { account.SetNull(); - return Read(make_pair(string("acc"), strAccount), account); + return Read(make_pair(std::string("acc"), strAccount), account); } -bool CWalletDB::WriteAccount(const string &strAccount, +bool CWalletDB::WriteAccount(const std::string &strAccount, const CAccount &account) { - return Write(make_pair(string("acc"), strAccount), account); + return Write(make_pair(std::string("acc"), strAccount), account); } bool CWalletDB::WriteAccountingEntry(const uint64_t nAccEntryNum, @@ -200,8 +198,8 @@ return WriteAccountingEntry(++nAccountingEntryNumber, acentry); } -CAmount CWalletDB::GetAccountCreditDebit(const string &strAccount) { - list entries; +CAmount CWalletDB::GetAccountCreditDebit(const std::string &strAccount) { + std::list entries; ListAccountCreditDebit(strAccount, entries); CAmount nCreditDebit = 0; @@ -212,13 +210,13 @@ return nCreditDebit; } -void CWalletDB::ListAccountCreditDebit(const string &strAccount, - list &entries) { +void CWalletDB::ListAccountCreditDebit(const std::string &strAccount, + std::list &entries) { bool fAllAccounts = (strAccount == "*"); Dbc *pcursor = GetCursor(); if (!pcursor) - throw runtime_error(std::string(__func__) + + throw std::runtime_error(std::string(__func__) + ": cannot create DB cursor"); bool setRange = true; while (true) { @@ -227,7 +225,7 @@ if (setRange) ssKey << std::make_pair( std::string("acentry"), - std::make_pair((fAllAccounts ? string("") : strAccount), + std::make_pair((fAllAccounts ? std::string("") : strAccount), uint64_t(0))); CDataStream ssValue(SER_DISK, CLIENT_VERSION); int ret = ReadAtCursor(pcursor, ssKey, ssValue, setRange); @@ -236,11 +234,11 @@ break; else if (ret != 0) { pcursor->close(); - throw runtime_error(std::string(__func__) + ": error scanning DB"); + throw std::runtime_error(std::string(__func__) + ": error scanning DB"); } // Unserialize - string strType; + std::string strType; ssKey >> strType; if (strType != "acentry") break; CAccountingEntry acentry; @@ -264,7 +262,7 @@ bool fIsEncrypted; bool fAnyUnordered; int nFileVersion; - vector vWalletUpgrade; + std::vector vWalletUpgrade; CWalletScanState() { nKeys = nCKeys = nWatchKeys = nKeyMeta = 0; @@ -275,19 +273,19 @@ }; bool ReadKeyValue(CWallet *pwallet, CDataStream &ssKey, CDataStream &ssValue, - CWalletScanState &wss, string &strType, string &strErr) { + CWalletScanState &wss, std::string &strType, std::string &strErr) { try { // Unserialize // Taking advantage of the fact that pair serialization is just the two // items serialized one after the other. ssKey >> strType; if (strType == "name") { - string strAddress; + std::string strAddress; ssKey >> strAddress; ssValue >> pwallet->mapAddressBook[CBitcoinAddress(strAddress).Get()].name; } else if (strType == "purpose") { - string strAddress; + std::string strAddress; ssKey >> strAddress; ssValue >> pwallet->mapAddressBook[CBitcoinAddress(strAddress).Get()] @@ -328,7 +326,7 @@ pwallet->LoadToWallet(wtx); } else if (strType == "acentry") { - string strAccount; + std::string strAccount; ssKey >> strAccount; uint64_t nNumber; ssKey >> nNumber; @@ -424,7 +422,7 @@ strErr = "Error reading wallet database: CPubKey corrupt"; return false; } - vector vchPrivKey; + std::vector vchPrivKey; ssValue >> vchPrivKey; wss.nCKeys++; @@ -497,7 +495,7 @@ return true; } -static bool IsKeyType(string strType) { +static bool IsKeyType(std::string strType) { return (strType == "key" || strType == "wkey" || strType == "mkey" || strType == "ckey"); } @@ -511,7 +509,7 @@ LOCK(pwallet->cs_wallet); try { int nMinVersion = 0; - if (Read((string) "minversion", nMinVersion)) { + if (Read((std::string) "minversion", nMinVersion)) { if (nMinVersion > CLIENT_VERSION) return DB_TOO_NEW; pwallet->LoadMinVersion(nMinVersion); } @@ -536,7 +534,7 @@ } // Try to be tolerant of single corrupt records: - string strType, strErr; + std::string strType, strErr; if (!ReadKeyValue(pwallet, ssKey, ssValue, wss, strType, strErr)) { // losing keys is considered a catastrophic error, anything else // we assume the user can live with: @@ -601,8 +599,8 @@ return result; } -DBErrors CWalletDB::FindWalletTx(CWallet *pwallet, vector &vTxHash, - vector &vWtx) { +DBErrors CWalletDB::FindWalletTx(CWallet *pwallet, std::vector &vTxHash, + std::vector &vWtx) { pwallet->vchDefaultKey = CPubKey(); bool fNoncriticalErrors = false; DBErrors result = DB_LOAD_OK; @@ -610,7 +608,7 @@ try { LOCK(pwallet->cs_wallet); int nMinVersion = 0; - if (Read((string) "minversion", nMinVersion)) { + if (Read((std::string) "minversion", nMinVersion)) { if (nMinVersion > CLIENT_VERSION) return DB_TOO_NEW; pwallet->LoadMinVersion(nMinVersion); } @@ -634,7 +632,7 @@ return DB_CORRUPT; } - string strType; + std::string strType; ssKey >> strType; if (strType == "tx") { uint256 hash; @@ -660,11 +658,11 @@ return result; } -DBErrors CWalletDB::ZapSelectTx(CWallet *pwallet, vector &vTxHashIn, - vector &vTxHashOut) { +DBErrors CWalletDB::ZapSelectTx(CWallet *pwallet, std::vector &vTxHashIn, + std::vector &vTxHashOut) { // Build list of wallet TXs and hashes. - vector vTxHash; - vector vWtx; + std::vector vTxHash; + std::vector vWtx; DBErrors err = FindWalletTx(pwallet, vTxHash, vWtx); if (err != DB_LOAD_OK) { return err; @@ -675,7 +673,7 @@ // Erase each matching wallet TX. bool delerror = false; - vector::iterator it = vTxHashIn.begin(); + std::vector::iterator it = vTxHashIn.begin(); for (uint256 hash : vTxHash) { while (it < vTxHashIn.end() && (*it) < hash) { it++; @@ -700,9 +698,9 @@ return DB_LOAD_OK; } -DBErrors CWalletDB::ZapWalletTx(CWallet *pwallet, vector &vWtx) { +DBErrors CWalletDB::ZapWalletTx(CWallet *pwallet, std::vector &vWtx) { // Build list of wallet TXs. - vector vTxHash; + std::vector vTxHash; DBErrors err = FindWalletTx(pwallet, vTxHash, vWtx); if (err != DB_LOAD_OK) return err; @@ -740,7 +738,7 @@ if (lockDb) { // Don't do this if any databases are in use. int nRefCount = 0; - map::iterator mi = bitdb.mapFileUseCount.begin(); + std::map::iterator mi = bitdb.mapFileUseCount.begin(); while (mi != bitdb.mapFileUseCount.end()) { nRefCount += (*mi).second; mi++; @@ -749,7 +747,7 @@ if (nRefCount == 0) { boost::this_thread::interruption_point(); const std::string &strFile = pwalletMain->strWalletFile; - map::iterator _mi = + std::map::iterator _mi = bitdb.mapFileUseCount.find(strFile); if (_mi != bitdb.mapFileUseCount.end()) { LogPrint("db", "Flushing %s\n", strFile); @@ -819,7 +817,7 @@ if (fOnlyKeys) { CDataStream ssKey(row.first, SER_DISK, CLIENT_VERSION); CDataStream ssValue(row.second, SER_DISK, CLIENT_VERSION); - string strType, strErr; + std::string strType, strErr; bool fReadOK; { // Required in LoadKeyMetadata():