Skip to content

Commit 23fb9ad

Browse files
committed
wallet: Move nAccountingEntryNumber from static/global to CWallet
1 parent 9d15d55 commit 23fb9ad

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2871,7 +2871,7 @@ bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry)
28712871

28722872
bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, CWalletDB *pwalletdb)
28732873
{
2874-
if (!pwalletdb->WriteAccountingEntry_Backend(acentry))
2874+
if (!pwalletdb->WriteAccountingEntry(++nAccountingEntryNumber, acentry))
28752875
return false;
28762876

28772877
laccentries.push_back(acentry);

src/wallet/wallet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
785785
nMasterKeyMaxID = 0;
786786
pwalletdbEncryption = NULL;
787787
nOrderPosNext = 0;
788+
nAccountingEntryNumber = 0;
788789
nNextResend = 0;
789790
nLastResend = 0;
790791
nTimeFirstKey = 0;
@@ -802,6 +803,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
802803
TxItems wtxOrdered;
803804

804805
int64_t nOrderPosNext;
806+
uint64_t nAccountingEntryNumber;
805807
std::map<uint256, int> mapRequestCount;
806808

807809
std::map<CTxDestination, CAddressBookData> mapAddressBook;

src/wallet/walletdb.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include <boost/foreach.hpp>
2323
#include <boost/thread.hpp>
2424

25-
static uint64_t nAccountingEntryNumber = 0;
26-
2725
static std::atomic<unsigned int> nWalletDBUpdateCounter;
2826

2927
//
@@ -180,11 +178,6 @@ bool CWalletDB::WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccount
180178
return WriteIC(std::make_pair(std::string("acentry"), std::make_pair(acentry.strAccount, nAccEntryNum)), acentry);
181179
}
182180

183-
bool CWalletDB::WriteAccountingEntry_Backend(const CAccountingEntry& acentry)
184-
{
185-
return WriteAccountingEntry(++nAccountingEntryNumber, acentry);
186-
}
187-
188181
CAmount CWalletDB::GetAccountCreditDebit(const std::string& strAccount)
189182
{
190183
std::list<CAccountingEntry> entries;
@@ -321,8 +314,9 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
321314
ssKey >> strAccount;
322315
uint64_t nNumber;
323316
ssKey >> nNumber;
324-
if (nNumber > nAccountingEntryNumber)
325-
nAccountingEntryNumber = nNumber;
317+
if (nNumber > pwallet->nAccountingEntryNumber) {
318+
pwallet->nAccountingEntryNumber = nNumber;
319+
}
326320

327321
if (!wss.fAnyUnordered)
328322
{

src/wallet/walletdb.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ class CWalletDB
201201
/// This writes directly to the database, and will not update the CWallet's cached accounting entries!
202202
/// Use wallet.AddAccountingEntry instead, to write *and* update its caches.
203203
bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry);
204-
bool WriteAccountingEntry_Backend(const CAccountingEntry& acentry);
205204
bool ReadAccount(const std::string& strAccount, CAccount& account);
206205
bool WriteAccount(const std::string& strAccount, const CAccount& account);
207206

0 commit comments

Comments
 (0)