diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2017-03-09 20:11:36 +0000 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2017-06-05 21:04:42 +0000 |
commit | 23fb9adaea01c7baece6e1269e65713571088c5f (patch) | |
tree | a5d502424da92afc409064d65627fcacc6cb8d20 /src/wallet | |
parent | 9d15d5548d375e7841e0505cdcf4ddcf11591994 (diff) |
wallet: Move nAccountingEntryNumber from static/global to CWallet
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet.cpp | 2 | ||||
-rw-r--r-- | src/wallet/wallet.h | 2 | ||||
-rw-r--r-- | src/wallet/walletdb.cpp | 12 | ||||
-rw-r--r-- | src/wallet/walletdb.h | 1 |
4 files changed, 6 insertions, 11 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3e000d2a9d..547daf5c62 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2871,7 +2871,7 @@ bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry) bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, CWalletDB *pwalletdb) { - if (!pwalletdb->WriteAccountingEntry_Backend(acentry)) + if (!pwalletdb->WriteAccountingEntry(++nAccountingEntryNumber, acentry)) return false; laccentries.push_back(acentry); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index a3974bf00b..6236b5e560 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -785,6 +785,7 @@ public: nMasterKeyMaxID = 0; pwalletdbEncryption = NULL; nOrderPosNext = 0; + nAccountingEntryNumber = 0; nNextResend = 0; nLastResend = 0; nTimeFirstKey = 0; @@ -802,6 +803,7 @@ public: TxItems wtxOrdered; int64_t nOrderPosNext; + uint64_t nAccountingEntryNumber; std::map<uint256, int> mapRequestCount; std::map<CTxDestination, CAddressBookData> mapAddressBook; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index f0d7f44ec0..75dbb2edff 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -22,8 +22,6 @@ #include <boost/foreach.hpp> #include <boost/thread.hpp> -static uint64_t nAccountingEntryNumber = 0; - static std::atomic<unsigned int> nWalletDBUpdateCounter; // @@ -180,11 +178,6 @@ bool CWalletDB::WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccount return WriteIC(std::make_pair(std::string("acentry"), std::make_pair(acentry.strAccount, nAccEntryNum)), acentry); } -bool CWalletDB::WriteAccountingEntry_Backend(const CAccountingEntry& acentry) -{ - return WriteAccountingEntry(++nAccountingEntryNumber, acentry); -} - CAmount CWalletDB::GetAccountCreditDebit(const std::string& strAccount) { std::list<CAccountingEntry> entries; @@ -321,8 +314,9 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, ssKey >> strAccount; uint64_t nNumber; ssKey >> nNumber; - if (nNumber > nAccountingEntryNumber) - nAccountingEntryNumber = nNumber; + if (nNumber > pwallet->nAccountingEntryNumber) { + pwallet->nAccountingEntryNumber = nNumber; + } if (!wss.fAnyUnordered) { diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 0fafdb6a1b..5f9aec9afd 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -201,7 +201,6 @@ public: /// This writes directly to the database, and will not update the CWallet's cached accounting entries! /// Use wallet.AddAccountingEntry instead, to write *and* update its caches. bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry); - bool WriteAccountingEntry_Backend(const CAccountingEntry& acentry); bool ReadAccount(const std::string& strAccount, CAccount& account); bool WriteAccount(const std::string& strAccount, const CAccount& account); |